1 | /* poppler-form-field.h: glib interface to poppler |
2 | * |
3 | * Copyright (C) 2007 Carlos Garcia Campos <carlosgc@gnome.org> |
4 | * Copyright (C) 2021 André Guerreiro <aguerreiro1985@gmail.com> |
5 | * Copyright (C) 2021, 2023 Marek Kasik <mkasik@redhat.com> |
6 | * |
7 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published by |
9 | * the Free Software Foundation; either version 2, or (at your option) |
10 | * any later version. |
11 | * |
12 | * This program is distributed in the hope that it will be useful, |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * GNU General Public License for more details. |
16 | * |
17 | * You should have received a copy of the GNU General Public License |
18 | * along with this program; if not, write to the Free Software |
19 | * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. |
20 | */ |
21 | |
22 | #ifndef __POPPLER_FORM_FIELD_H__ |
23 | #define __POPPLER_FORM_FIELD_H__ |
24 | |
25 | #include <glib-object.h> |
26 | #include "poppler.h" |
27 | |
28 | G_BEGIN_DECLS |
29 | |
30 | #define POPPLER_TYPE_FORM_FIELD (poppler_form_field_get_type()) |
31 | #define POPPLER_FORM_FIELD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), POPPLER_TYPE_FORM_FIELD, PopplerFormField)) |
32 | #define POPPLER_IS_FORM_FIELD(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), POPPLER_TYPE_FORM_FIELD)) |
33 | |
34 | /** |
35 | * PopplerSignatureStatus |
36 | * @POPPLER_SIGNATURE_VALID: signature is cryptographically valid |
37 | * @POPPLER_SIGNATURE_INVALID: signature is cryptographically invalid |
38 | * @POPPLER_SIGNATURE_DIGEST_MISMATCH: document content was changed after the signature was applied |
39 | * @POPPLER_SIGNATURE_DECODING_ERROR: signature CMS/PKCS7 structure is malformed |
40 | * @POPPLER_SIGNATURE_GENERIC_ERROR: failed to verify signature |
41 | * @POPPLER_SIGNATURE_NOT_FOUND: requested signature is not present in the document |
42 | * @POPPLER_SIGNATURE_NOT_VERIFIED: signature not yet verified |
43 | * |
44 | * Signature verification results |
45 | * |
46 | * Since: 21.12.0 |
47 | */ |
48 | typedef enum |
49 | { |
50 | POPPLER_SIGNATURE_VALID, |
51 | POPPLER_SIGNATURE_INVALID, |
52 | POPPLER_SIGNATURE_DIGEST_MISMATCH, |
53 | POPPLER_SIGNATURE_DECODING_ERROR, |
54 | POPPLER_SIGNATURE_GENERIC_ERROR, |
55 | POPPLER_SIGNATURE_NOT_FOUND, |
56 | POPPLER_SIGNATURE_NOT_VERIFIED |
57 | } PopplerSignatureStatus; |
58 | |
59 | /** |
60 | * PopplerCertificateStatus |
61 | * @POPPLER_CERTIFICATE_TRUSTED: certificate is considered trusted |
62 | * @POPPLER_CERTIFICATE_UNTRUSTED_ISSUER: the issuer of this certificate has been marked as untrusted by the user |
63 | * @POPPLER_CERTIFICATE_UNKNOWN_ISSUER: this certificate trust chain has not finished in a trusted root certificate |
64 | * @POPPLER_CERTIFICATE_REVOKED: certificate was revoked by the issuing certificate authority |
65 | * @POPPLER_CERTIFICATE_EXPIRED: signing time is outside the validity bounds of this certificate |
66 | * @POPPLER_CERTIFICATE_GENERIC_ERROR: failed to verify certificate |
67 | * @POPPLER_CERTIFICATE_NOT_VERIFIED: certificate not yet verified |
68 | * |
69 | * Signature certificate verification results |
70 | * |
71 | * Since: 21.12.0 |
72 | */ |
73 | typedef enum |
74 | { |
75 | POPPLER_CERTIFICATE_TRUSTED, |
76 | POPPLER_CERTIFICATE_UNTRUSTED_ISSUER, |
77 | POPPLER_CERTIFICATE_UNKNOWN_ISSUER, |
78 | POPPLER_CERTIFICATE_REVOKED, |
79 | POPPLER_CERTIFICATE_EXPIRED, |
80 | POPPLER_CERTIFICATE_GENERIC_ERROR, |
81 | POPPLER_CERTIFICATE_NOT_VERIFIED |
82 | } PopplerCertificateStatus; |
83 | |
84 | /** |
85 | * PopplerSignatureValidationFlags |
86 | * @POPPLER_SIGNATURE_VALIDATION_FLAG_VALIDATE_CERTIFICATE: Whether to validate also the certificate of the signature |
87 | * @POPPLER_SIGNATURE_VALIDATION_FLAG_WITHOUT_OCSP_REVOCATION_CHECK: Whether to not do OCSP (Online Certificate Status Protocol) revocation check |
88 | * @POPPLER_SIGNATURE_VALIDATION_FLAG_USE_AIA_CERTIFICATE_FETCH: Whether to use AIA (Authority Information Access) extension for certificate fetching |
89 | * |
90 | * Signature validation flags |
91 | * |
92 | * Since: 21.12.0 |
93 | */ |
94 | typedef enum /*< flags >*/ |
95 | { |
96 | POPPLER_SIGNATURE_VALIDATION_FLAG_VALIDATE_CERTIFICATE = 1 << 0, |
97 | POPPLER_SIGNATURE_VALIDATION_FLAG_WITHOUT_OCSP_REVOCATION_CHECK = 1 << 1, |
98 | POPPLER_SIGNATURE_VALIDATION_FLAG_USE_AIA_CERTIFICATE_FETCH = 1 << 2, |
99 | } PopplerSignatureValidationFlags; |
100 | |
101 | typedef enum |
102 | { |
103 | POPPLER_FORM_FIELD_UNKNOWN, |
104 | POPPLER_FORM_FIELD_BUTTON, |
105 | POPPLER_FORM_FIELD_TEXT, |
106 | POPPLER_FORM_FIELD_CHOICE, |
107 | POPPLER_FORM_FIELD_SIGNATURE |
108 | } PopplerFormFieldType; |
109 | |
110 | typedef enum |
111 | { |
112 | POPPLER_FORM_BUTTON_PUSH, |
113 | POPPLER_FORM_BUTTON_CHECK, |
114 | POPPLER_FORM_BUTTON_RADIO |
115 | } PopplerFormButtonType; |
116 | |
117 | typedef enum |
118 | { |
119 | POPPLER_FORM_TEXT_NORMAL, |
120 | POPPLER_FORM_TEXT_MULTILINE, |
121 | POPPLER_FORM_TEXT_FILE_SELECT |
122 | } PopplerFormTextType; |
123 | |
124 | typedef enum |
125 | { |
126 | POPPLER_FORM_CHOICE_COMBO, |
127 | POPPLER_FORM_CHOICE_LIST |
128 | } PopplerFormChoiceType; |
129 | |
130 | /** |
131 | * PopplerAdditionalActionType: |
132 | * @POPPLER_ADDITIONAL_ACTION_FIELD_MODIFIED: The action to be performed when the user modifies the field. |
133 | * @POPPLER_ADDITIONAL_ACTION_FORMAT_FIELD: The action to be performed before the field is formatted to |
134 | * display its value. |
135 | * @POPPLER_ADDITIONAL_ACTION_VALIDATE_FIELD: The action to be performed when the field value changes. |
136 | * @POPPLER_ADDITIONAL_ACTION_CALCULATE_FIELD: The action to be performed when the field needs to be |
137 | * recalculated. |
138 | * |
139 | * Form field additional action types to be passed to @poppler_form_field_get_additional_action |
140 | * |
141 | * Since: 0.72 |
142 | */ |
143 | typedef enum |
144 | { |
145 | POPPLER_ADDITIONAL_ACTION_FIELD_MODIFIED, |
146 | POPPLER_ADDITIONAL_ACTION_FORMAT_FIELD, |
147 | POPPLER_ADDITIONAL_ACTION_VALIDATE_FIELD, |
148 | POPPLER_ADDITIONAL_ACTION_CALCULATE_FIELD |
149 | } PopplerAdditionalActionType; |
150 | |
151 | POPPLER_PUBLIC |
152 | GType poppler_form_field_get_type(void) G_GNUC_CONST; |
153 | |
154 | POPPLER_PUBLIC |
155 | PopplerFormFieldType poppler_form_field_get_field_type(PopplerFormField *field); |
156 | POPPLER_PUBLIC |
157 | gint poppler_form_field_get_id(PopplerFormField *field); |
158 | POPPLER_PUBLIC |
159 | gdouble poppler_form_field_get_font_size(PopplerFormField *field); |
160 | POPPLER_PUBLIC |
161 | gboolean poppler_form_field_is_read_only(PopplerFormField *field); |
162 | POPPLER_PUBLIC |
163 | gchar *poppler_form_field_get_partial_name(PopplerFormField *field); |
164 | POPPLER_PUBLIC |
165 | gchar *poppler_form_field_get_mapping_name(PopplerFormField *field); |
166 | POPPLER_PUBLIC |
167 | gchar *poppler_form_field_get_name(PopplerFormField *field); |
168 | POPPLER_PUBLIC |
169 | PopplerAction *poppler_form_field_get_action(PopplerFormField *field); |
170 | POPPLER_PUBLIC |
171 | PopplerAction *poppler_form_field_get_additional_action(PopplerFormField *field, PopplerAdditionalActionType type); |
172 | POPPLER_PUBLIC |
173 | gchar *poppler_form_field_get_alternate_ui_name(PopplerFormField *field); |
174 | |
175 | /* Button Field */ |
176 | POPPLER_PUBLIC |
177 | PopplerFormButtonType poppler_form_field_button_get_button_type(PopplerFormField *field); |
178 | POPPLER_PUBLIC |
179 | gboolean poppler_form_field_button_get_state(PopplerFormField *field); |
180 | POPPLER_PUBLIC |
181 | void poppler_form_field_button_set_state(PopplerFormField *field, gboolean state); |
182 | |
183 | /* Text Field */ |
184 | POPPLER_PUBLIC |
185 | PopplerFormTextType poppler_form_field_text_get_text_type(PopplerFormField *field); |
186 | POPPLER_PUBLIC |
187 | gchar *poppler_form_field_text_get_text(PopplerFormField *field); |
188 | POPPLER_PUBLIC |
189 | void poppler_form_field_text_set_text(PopplerFormField *field, const gchar *text); |
190 | POPPLER_PUBLIC |
191 | gint poppler_form_field_text_get_max_len(PopplerFormField *field); |
192 | POPPLER_PUBLIC |
193 | gboolean poppler_form_field_text_do_spell_check(PopplerFormField *field); |
194 | POPPLER_PUBLIC |
195 | gboolean poppler_form_field_text_do_scroll(PopplerFormField *field); |
196 | POPPLER_PUBLIC |
197 | gboolean poppler_form_field_text_is_rich_text(PopplerFormField *field); |
198 | POPPLER_PUBLIC |
199 | gboolean poppler_form_field_text_is_password(PopplerFormField *field); |
200 | |
201 | /* Choice Field */ |
202 | POPPLER_PUBLIC |
203 | PopplerFormChoiceType poppler_form_field_choice_get_choice_type(PopplerFormField *field); |
204 | POPPLER_PUBLIC |
205 | gboolean poppler_form_field_choice_is_editable(PopplerFormField *field); |
206 | POPPLER_PUBLIC |
207 | gboolean poppler_form_field_choice_can_select_multiple(PopplerFormField *field); |
208 | POPPLER_PUBLIC |
209 | gboolean poppler_form_field_choice_do_spell_check(PopplerFormField *field); |
210 | POPPLER_PUBLIC |
211 | gboolean poppler_form_field_choice_commit_on_change(PopplerFormField *field); |
212 | POPPLER_PUBLIC |
213 | gint poppler_form_field_choice_get_n_items(PopplerFormField *field); |
214 | POPPLER_PUBLIC |
215 | gchar *poppler_form_field_choice_get_item(PopplerFormField *field, gint index); |
216 | POPPLER_PUBLIC |
217 | gboolean poppler_form_field_choice_is_item_selected(PopplerFormField *field, gint index); |
218 | POPPLER_PUBLIC |
219 | void poppler_form_field_choice_select_item(PopplerFormField *field, gint index); |
220 | POPPLER_PUBLIC |
221 | void poppler_form_field_choice_unselect_all(PopplerFormField *field); |
222 | POPPLER_PUBLIC |
223 | void poppler_form_field_choice_toggle_item(PopplerFormField *field, gint index); |
224 | POPPLER_PUBLIC |
225 | void poppler_form_field_choice_set_text(PopplerFormField *field, const gchar *text); |
226 | POPPLER_PUBLIC |
227 | gchar *poppler_form_field_choice_get_text(PopplerFormField *field); |
228 | POPPLER_PUBLIC |
229 | PopplerSignatureInfo *poppler_form_field_signature_validate_sync(PopplerFormField *field, PopplerSignatureValidationFlags flags, GCancellable *cancellable, GError **error); |
230 | POPPLER_PUBLIC |
231 | void poppler_form_field_signature_validate_async(PopplerFormField *field, PopplerSignatureValidationFlags flags, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); |
232 | POPPLER_PUBLIC |
233 | PopplerSignatureInfo *poppler_form_field_signature_validate_finish(PopplerFormField *field, GAsyncResult *result, GError **error); |
234 | |
235 | /* Signature Field */ |
236 | #define POPPLER_TYPE_SIGNATURE_INFO (poppler_signature_info_get_type()) |
237 | POPPLER_PUBLIC |
238 | GType poppler_signature_info_get_type(void) G_GNUC_CONST; |
239 | POPPLER_PUBLIC |
240 | PopplerSignatureInfo *poppler_signature_info_copy(const PopplerSignatureInfo *siginfo); |
241 | POPPLER_PUBLIC |
242 | void poppler_signature_info_free(PopplerSignatureInfo *siginfo); |
243 | POPPLER_PUBLIC |
244 | PopplerSignatureStatus poppler_signature_info_get_signature_status(const PopplerSignatureInfo *siginfo); |
245 | POPPLER_PUBLIC |
246 | PopplerCertificateStatus poppler_signature_info_get_certificate_status(const PopplerSignatureInfo *siginfo); |
247 | POPPLER_PUBLIC |
248 | PopplerCertificateInfo *poppler_signature_info_get_certificate_info(const PopplerSignatureInfo *siginfo); |
249 | POPPLER_PUBLIC |
250 | const gchar *poppler_signature_info_get_signer_name(const PopplerSignatureInfo *siginfo); |
251 | POPPLER_PUBLIC |
252 | GDateTime *poppler_signature_info_get_local_signing_time(const PopplerSignatureInfo *siginfo); |
253 | |
254 | /* Signing Data */ |
255 | #define POPPLER_TYPE_SIGNING_DATA (poppler_signing_data_get_type()) |
256 | POPPLER_PUBLIC |
257 | GType poppler_signing_data_get_type(void) G_GNUC_CONST; |
258 | POPPLER_PUBLIC |
259 | PopplerSigningData *poppler_signing_data_new(void); |
260 | POPPLER_PUBLIC |
261 | PopplerSigningData *poppler_signing_data_copy(const PopplerSigningData *signing_data); |
262 | POPPLER_PUBLIC |
263 | void poppler_signing_data_free(PopplerSigningData *signing_data); |
264 | POPPLER_PUBLIC |
265 | void poppler_signing_data_set_destination_filename(PopplerSigningData *signing_data, const gchar *filename); |
266 | POPPLER_PUBLIC |
267 | const gchar *poppler_signing_data_get_destination_filename(const PopplerSigningData *signing_data); |
268 | POPPLER_PUBLIC |
269 | void poppler_signing_data_set_certificate_info(PopplerSigningData *signing_data, const PopplerCertificateInfo *certificate_info); |
270 | POPPLER_PUBLIC |
271 | const PopplerCertificateInfo *poppler_signing_data_get_certificate_info(const PopplerSigningData *signing_data); |
272 | POPPLER_PUBLIC |
273 | void poppler_signing_data_set_page(PopplerSigningData *signing_data, int page); |
274 | POPPLER_PUBLIC |
275 | int poppler_signing_data_get_page(const PopplerSigningData *signing_data); |
276 | POPPLER_PUBLIC |
277 | void poppler_signing_data_set_signature_text(PopplerSigningData *signing_data, const gchar *signature_text); |
278 | POPPLER_PUBLIC |
279 | const gchar *poppler_signing_data_get_signature_text(const PopplerSigningData *signing_data); |
280 | POPPLER_PUBLIC |
281 | void poppler_signing_data_set_signature_text_left(PopplerSigningData *signing_data, const gchar *signature_text_left); |
282 | POPPLER_PUBLIC |
283 | const gchar *poppler_signing_data_get_signature_text_left(const PopplerSigningData *signing_data); |
284 | POPPLER_PUBLIC |
285 | void poppler_signing_data_set_signature_rectangle(PopplerSigningData *signing_data, const PopplerRectangle *signature_rect); |
286 | POPPLER_PUBLIC |
287 | const PopplerRectangle *poppler_signing_data_get_signature_rectangle(const PopplerSigningData *signing_data); |
288 | POPPLER_PUBLIC |
289 | void poppler_signing_data_set_font_color(PopplerSigningData *signing_data, const PopplerColor *font_color); |
290 | POPPLER_PUBLIC |
291 | const PopplerColor *poppler_signing_data_get_font_color(const PopplerSigningData *signing_data); |
292 | POPPLER_PUBLIC |
293 | void poppler_signing_data_set_font_size(PopplerSigningData *signing_data, gdouble font_size); |
294 | POPPLER_PUBLIC |
295 | gdouble poppler_signing_data_get_font_size(const PopplerSigningData *signing_data); |
296 | POPPLER_PUBLIC |
297 | void poppler_signing_data_set_left_font_size(PopplerSigningData *signing_data, gdouble font_size); |
298 | POPPLER_PUBLIC |
299 | gdouble poppler_signing_data_get_left_font_size(const PopplerSigningData *signing_data); |
300 | POPPLER_PUBLIC |
301 | void poppler_signing_data_set_border_color(PopplerSigningData *signing_data, const PopplerColor *border_color); |
302 | POPPLER_PUBLIC |
303 | const PopplerColor *poppler_signing_data_get_border_color(const PopplerSigningData *signing_data); |
304 | POPPLER_PUBLIC |
305 | void poppler_signing_data_set_border_width(PopplerSigningData *signing_data, gdouble border_width); |
306 | POPPLER_PUBLIC |
307 | gdouble poppler_signing_data_get_border_width(const PopplerSigningData *signing_data); |
308 | POPPLER_PUBLIC |
309 | void poppler_signing_data_set_background_color(PopplerSigningData *signing_data, const PopplerColor *background_color); |
310 | POPPLER_PUBLIC |
311 | const PopplerColor *poppler_signing_data_get_background_color(const PopplerSigningData *signing_data); |
312 | POPPLER_PUBLIC |
313 | void poppler_signing_data_set_field_partial_name(PopplerSigningData *signing_data, const gchar *field_partial_name); |
314 | POPPLER_PUBLIC |
315 | const gchar *poppler_signing_data_get_field_partial_name(const PopplerSigningData *signing_data); |
316 | POPPLER_PUBLIC |
317 | void poppler_signing_data_set_reason(PopplerSigningData *signing_data, const gchar *reason); |
318 | POPPLER_PUBLIC |
319 | const gchar *poppler_signing_data_get_reason(const PopplerSigningData *signing_data); |
320 | POPPLER_PUBLIC |
321 | void poppler_signing_data_set_location(PopplerSigningData *signing_data, const gchar *location); |
322 | POPPLER_PUBLIC |
323 | const gchar *poppler_signing_data_get_location(const PopplerSigningData *signing_data); |
324 | POPPLER_PUBLIC |
325 | void poppler_signing_data_set_image_path(PopplerSigningData *signing_data, const gchar *image_path); |
326 | POPPLER_PUBLIC |
327 | const gchar *poppler_signing_data_get_image_path(const PopplerSigningData *signing_data); |
328 | POPPLER_PUBLIC |
329 | void poppler_signing_data_set_password(PopplerSigningData *signing_data, const gchar *password); |
330 | POPPLER_PUBLIC |
331 | const gchar *poppler_signing_data_get_password(const PopplerSigningData *signing_data); |
332 | POPPLER_PUBLIC |
333 | void poppler_signing_data_set_document_owner_password(PopplerSigningData *signing_data, const gchar *document_owner_password); |
334 | POPPLER_PUBLIC |
335 | const gchar *poppler_signing_data_get_document_owner_password(const PopplerSigningData *signing_data); |
336 | POPPLER_PUBLIC |
337 | void poppler_signing_data_set_document_user_password(PopplerSigningData *signing_data, const gchar *document_user_password); |
338 | POPPLER_PUBLIC |
339 | const gchar *poppler_signing_data_get_document_user_password(const PopplerSigningData *signing_data); |
340 | |
341 | /* Certificate Information */ |
342 | #define POPPLER_TYPE_CERTIFICATE_INFO (poppler_certificate_info_get_type()) |
343 | POPPLER_PUBLIC |
344 | GType poppler_certificate_info_get_type(void) G_GNUC_CONST; |
345 | PopplerCertificateInfo *poppler_certificate_info_new(void); |
346 | POPPLER_PUBLIC |
347 | PopplerCertificateInfo *poppler_certificate_info_copy(const PopplerCertificateInfo *certificate_info); |
348 | POPPLER_PUBLIC |
349 | void poppler_certificate_info_free(PopplerCertificateInfo *certificate_info); |
350 | POPPLER_PUBLIC |
351 | const char *poppler_certificate_info_get_id(const PopplerCertificateInfo *certificate_info); |
352 | POPPLER_PUBLIC |
353 | const char *poppler_certificate_info_get_subject_common_name(const PopplerCertificateInfo *certificate_info); |
354 | POPPLER_PUBLIC |
355 | const char *poppler_certificate_info_get_subject_organization(const PopplerCertificateInfo *certificate_info); |
356 | POPPLER_PUBLIC |
357 | const char *poppler_certificate_info_get_subject_email(const PopplerCertificateInfo *certificate_info); |
358 | POPPLER_PUBLIC |
359 | const char *poppler_certificate_info_get_issuer_common_name(const PopplerCertificateInfo *certificate_info); |
360 | POPPLER_PUBLIC |
361 | const char *poppler_certificate_info_get_issuer_organization(const PopplerCertificateInfo *certificate_info); |
362 | POPPLER_PUBLIC |
363 | const char *poppler_certificate_info_get_issuer_email(const PopplerCertificateInfo *certificate_info); |
364 | POPPLER_PUBLIC |
365 | GDateTime *poppler_certificate_info_get_issuance_time(const PopplerCertificateInfo *certificate_info); |
366 | POPPLER_PUBLIC |
367 | GDateTime *poppler_certificate_info_get_expiration_time(const PopplerCertificateInfo *certificate_info); |
368 | POPPLER_PUBLIC |
369 | PopplerCertificateInfo *poppler_get_certificate_info_by_id(const char *id); |
370 | POPPLER_PUBLIC |
371 | GList *poppler_get_available_signing_certificates(void); |
372 | |
373 | /* NSS */ |
374 | POPPLER_PUBLIC |
375 | void poppler_set_nss_dir(const char *path); |
376 | POPPLER_PUBLIC |
377 | char *poppler_get_nss_dir(void); |
378 | typedef char *(*PopplerNssPasswordFunc)(const gchar *text); |
379 | POPPLER_PUBLIC |
380 | void poppler_set_nss_password_callback(PopplerNssPasswordFunc func); |
381 | |
382 | G_END_DECLS |
383 | |
384 | #endif /* __POPPLER_FORM_FIELD_H__ */ |
385 | |