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
27G_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 */
50typedef 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 */
67struct _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 */
93typedef struct _PopplerAttachmentClass
94{
95 GObjectClass parent_class;
96} PopplerAttachmentClass;
97
98POPPLER_PUBLIC
99GType poppler_attachment_get_type(void) G_GNUC_CONST;
100POPPLER_PUBLIC
101const GString *poppler_attachment_get_checksum(PopplerAttachment *attachment);
102POPPLER_PUBLIC
103GDateTime *poppler_attachment_get_ctime(PopplerAttachment *attachment);
104POPPLER_PUBLIC
105const gchar *poppler_attachment_get_description(PopplerAttachment *attachment);
106POPPLER_PUBLIC
107GDateTime *poppler_attachment_get_mtime(PopplerAttachment *attachment);
108POPPLER_PUBLIC
109const gchar *poppler_attachment_get_name(PopplerAttachment *attachment);
110POPPLER_PUBLIC
111gsize poppler_attachment_get_size(PopplerAttachment *attachment);
112POPPLER_PUBLIC
113gboolean poppler_attachment_save(PopplerAttachment *attachment, const char *filename, GError **error);
114#ifndef G_OS_WIN32
115POPPLER_PUBLIC
116gboolean poppler_attachment_save_to_fd(PopplerAttachment *attachment, int fd, GError **error);
117#endif
118POPPLER_PUBLIC
119gboolean poppler_attachment_save_to_callback(PopplerAttachment *attachment, PopplerAttachmentSaveFunc save_func, gpointer user_data, GError **error);
120
121G_END_DECLS
122
123#endif /* __POPPLER_ATTACHMENT_H__ */
124

source code of poppler/glib/poppler-attachment.h