1 | /* poppler-attachment.h: glib interface to poppler |
2 | * Copyright (C) 2004, Red Hat, Inc. |
3 | * |
4 | * This program is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License as published by |
6 | * the Free Software Foundation; either version 2, or (at your option) |
7 | * any later version. |
8 | * |
9 | * This program is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU General Public License |
15 | * along with this program; if not, write to the Free Software |
16 | * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. |
17 | */ |
18 | |
19 | #ifndef __POPPLER_ATTACHMENT_H__ |
20 | #define __POPPLER_ATTACHMENT_H__ |
21 | |
22 | #include <glib.h> |
23 | #include <glib-object.h> |
24 | |
25 | #include "poppler.h" |
26 | |
27 | G_BEGIN_DECLS |
28 | |
29 | #define POPPLER_TYPE_ATTACHMENT (poppler_attachment_get_type()) |
30 | #define POPPLER_ATTACHMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), POPPLER_TYPE_ATTACHMENT, PopplerAttachment)) |
31 | #define POPPLER_IS_ATTACHMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), POPPLER_TYPE_ATTACHMENT)) |
32 | |
33 | /** |
34 | * PopplerAttachmentSaveFunc: |
35 | * @buf: (array length=count) (element-type guint8): buffer containing |
36 | * bytes to be written. |
37 | * @count: number of bytes in @buf. |
38 | * @data: (closure): user data passed to poppler_attachment_save_to_callback() |
39 | * @error: GError to set on error, or %NULL |
40 | * |
41 | * Specifies the type of the function passed to |
42 | * poppler_attachment_save_to_callback(). It is called once for each block of |
43 | * bytes that is "written" by poppler_attachment_save_to_callback(). If |
44 | * successful it should return %TRUE. If an error occurs it should set |
45 | * @error and return %FALSE, in which case poppler_attachment_save_to_callback() |
46 | * will fail with the same error. |
47 | * |
48 | * Returns: %TRUE if successful, %FALSE (with @error set) if failed. |
49 | */ |
50 | typedef gboolean (*PopplerAttachmentSaveFunc)(const gchar *buf, gsize count, gpointer data, GError **error); |
51 | |
52 | /** |
53 | * PopplerAttachment: |
54 | * @name: The filename. Deprecated in poppler 20.09.0. Use |
55 | * poppler_attachment_get_name() instead. |
56 | * @description: Descriptive text. Deprecated in poppler 20.09.0. Use |
57 | * poppler_attachment_get_description() instead. |
58 | * @size: The size of the file. Deprecated in poppler 20.09.0. Use |
59 | * poppler_attachment_get_size() instead. |
60 | * @mtime: The date and time when the file was last modified. Deprecated in |
61 | * poppler 20.09.0. Use poppler_attachment_get_mtime() instead. |
62 | * @ctime: The date and time when the file was created. Deprecated in poppler |
63 | * 20.09.0. Use poppler_attachment_get_ctime() instead. |
64 | * @checksum: A 16-byte checksum of the file. Deprecated in poppler 20.09.0. Use |
65 | * poppler_attachment_get_checksum() instead. |
66 | */ |
67 | struct _PopplerAttachment |
68 | { |
69 | GObject parent; |
70 | |
71 | /*< public >*/ |
72 | gchar *name; |
73 | gchar *description; |
74 | gsize size; |
75 | |
76 | /* GTime is deprecated, but is part of our ABI here (see #715, #765). */ |
77 | G_GNUC_BEGIN_IGNORE_DEPRECATIONS |
78 | GTime mtime; |
79 | GTime ctime; |
80 | G_GNUC_END_IGNORE_DEPRECATIONS |
81 | |
82 | GString *checksum; |
83 | }; |
84 | |
85 | /* This struct was not intended to be public, but can't be moved to |
86 | * poppler-attachment.cc without breaking the API stability. |
87 | */ |
88 | /** |
89 | * PopplerAttachmentClass: |
90 | * |
91 | * The GObject class structure of #PopplerAttachment. |
92 | */ |
93 | typedef struct _PopplerAttachmentClass |
94 | { |
95 | GObjectClass parent_class; |
96 | } PopplerAttachmentClass; |
97 | |
98 | POPPLER_PUBLIC |
99 | GType poppler_attachment_get_type(void) G_GNUC_CONST; |
100 | POPPLER_PUBLIC |
101 | const GString *poppler_attachment_get_checksum(PopplerAttachment *attachment); |
102 | POPPLER_PUBLIC |
103 | GDateTime *poppler_attachment_get_ctime(PopplerAttachment *attachment); |
104 | POPPLER_PUBLIC |
105 | const gchar *poppler_attachment_get_description(PopplerAttachment *attachment); |
106 | POPPLER_PUBLIC |
107 | GDateTime *poppler_attachment_get_mtime(PopplerAttachment *attachment); |
108 | POPPLER_PUBLIC |
109 | const gchar *poppler_attachment_get_name(PopplerAttachment *attachment); |
110 | POPPLER_PUBLIC |
111 | gsize poppler_attachment_get_size(PopplerAttachment *attachment); |
112 | POPPLER_PUBLIC |
113 | gboolean poppler_attachment_save(PopplerAttachment *attachment, const char *filename, GError **error); |
114 | #ifndef G_OS_WIN32 |
115 | POPPLER_PUBLIC |
116 | gboolean poppler_attachment_save_to_fd(PopplerAttachment *attachment, int fd, GError **error); |
117 | #endif |
118 | POPPLER_PUBLIC |
119 | gboolean poppler_attachment_save_to_callback(PopplerAttachment *attachment, PopplerAttachmentSaveFunc save_func, gpointer user_data, GError **error); |
120 | |
121 | G_END_DECLS |
122 | |
123 | #endif /* __POPPLER_ATTACHMENT_H__ */ |
124 | |