summaryrefslogtreecommitdiff
path: root/src/fr-archive.h
blob: ae8514f14a0c0e3b22bcccd295c488b5c6ab9f69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */

/*
 *  Engrampa
 *
 *  Copyright (C) 2001, 2003 Free Software Foundation, Inc.
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#ifndef FR_ARCHIVE_H
#define FR_ARCHIVE_H

#include <glib.h>
#include "fr-process.h"
#include "fr-command.h"

#define FR_TYPE_ARCHIVE            (fr_archive_get_type ())
#define FR_ARCHIVE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), FR_TYPE_ARCHIVE, FrArchive))
#define FR_ARCHIVE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), FR_TYPE_ARCHIVE, FrArchiveClass))
#define FR_IS_ARCHIVE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FR_TYPE_ARCHIVE))
#define FR_IS_ARCHIVE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), FR_TYPE_ARCHIVE))
#define FR_ARCHIVE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), FR_TYPE_ARCHIVE, FrArchiveClass))

typedef struct _FrArchive         FrArchive;
typedef struct _FrArchiveClass    FrArchiveClass;
typedef struct _FrArchivePrivData FrArchivePrivData;

typedef gboolean (*FakeLoadFunc) (FrArchive *archive, gpointer data);

struct _FrArchive {
	GObject  __parent;

	GFile       *file;
	GFile       *local_copy;
	gboolean     is_remote;
	const char  *content_type;
	FrCommand   *command;
	FrProcess   *process;
	FrProcError  error;
	gboolean     can_create_compressed_file;
	gboolean     is_compressed_file;         /* Whether the file is not an
						  * archive that can contain
						  * many files but simply a
						  * compressed file, for
						  * example foo.txt.gz is a
						  * compressed file, foo.zip
						  * is not. */
	gboolean     read_only;                  /* Whether archive is
						  * read-only for whatever
						  * reason. */
	gboolean     have_permissions;           /* true if we have the
						  * permissions to write the
						  * file. */

	FrArchivePrivData *priv;
};

struct _FrArchiveClass {
	GObjectClass __parent_class;

	/* -- Signals -- */

	void (*start)            (FrArchive   *archive,
			          FrAction     action);
	void (*done)             (FrArchive   *archive,
			          FrAction     action,
			          FrProcError *error);
	void (*progress)         (FrArchive   *archive,
			          double       fraction);
	void (*message)          (FrArchive   *archive,
			          const char  *msg);
	void (*stoppable)        (FrArchive   *archive,
			          gboolean     value);
	void (*working_archive)  (FrCommand   *comm,
			          const char  *filename);
};

GType       fr_archive_get_type                  (void);
FrArchive * fr_archive_new                       (void);
void        fr_archive_set_fake_load_func        (FrArchive       *archive,
						  FakeLoadFunc     func,
						  gpointer         data);
gboolean    fr_archive_fake_load                 (FrArchive       *archive);
void        fr_archive_stoppable                 (FrArchive       *archive,
						  gboolean         stoppable);
void        fr_archive_stop	                 (FrArchive       *archive);
void        fr_archive_action_completed          (FrArchive       *archive,
						  FrAction         action,
						  FrProcErrorType  error_type,
						  const char      *error_details);

/**/

gboolean    fr_archive_create                    (FrArchive       *archive,
						  const char      *uri);
gboolean    fr_archive_load                      (FrArchive       *archive,
						  const char      *uri,
						  const char      *password);
gboolean    fr_archive_load_local                (FrArchive       *archive,
		       				  const char      *uri,
		       				  const char      *password);
void        fr_archive_reload                    (FrArchive       *archive,
						  const char      *password);

/**/

void        fr_archive_add                       (FrArchive       *archive,
						  GList           *file_list,
						  const char      *base_dir,
						  const char      *dest_dir,
						  gboolean         update,
						  gboolean         recursive,
						  const char      *password,
						  gboolean         encrypt_header,
						  FrCompression    compression,
						  guint            volume_size);
void        fr_archive_remove                    (FrArchive       *archive,
						  GList           *file_list,
						  FrCompression    compression);
void        fr_archive_extract                   (FrArchive       *archive,
						  GList           *file_list,
						  const char      *dest_uri,
						  const char      *base_dir,
						  gboolean         skip_older,
						  gboolean         overwrite,
						  gboolean         junk_path,
						  const char      *password);
void        fr_archive_extract_to_local          (FrArchive       *archive,
						  GList           *file_list,
						  const char      *dest_path,
						  const char      *base_dir,
						  gboolean         skip_older,
						  gboolean         overwrite,
						  gboolean         junk_path,
						  const char      *password);
gboolean    fr_archive_extract_here              (FrArchive       *archive,
						  gboolean         skip_older,
						  gboolean         overwrite,
						  gboolean         junk_path,
						  const char      *password);
const char *fr_archive_get_last_extraction_destination
						 (FrArchive       *archive);

/**/

void        fr_archive_add_files                 (FrArchive       *archive,
						  GList           *file_list,
						  const char      *base_dir,
						  const char      *dest_dir,
						  gboolean         update,
						  const char      *password,
						  gboolean         encrypt_header,
						  FrCompression    compression,
						  guint            volume_size);
void        fr_archive_add_with_wildcard         (FrArchive       *archive,
						  const char      *include_files,
						  const char      *exclude_files,
						  const char      *exclude_folders,
						  const char      *base_dir,
						  const char      *dest_dir,
						  gboolean         update,
						  gboolean         follow_links,
						  const char      *password,
						  gboolean         encrypt_header,
						  FrCompression    compression,
						  guint            volume_size);
void        fr_archive_add_directory             (FrArchive       *archive,
						  const char      *directory,
						  const char      *base_dir,
						  const char      *dest_dir,
						  gboolean         update,
						  const char      *password,
						  gboolean         encrypt_header,
						  FrCompression    compression,
						  guint            volume_size);
void        fr_archive_add_items                 (FrArchive       *archive,
						  GList           *item_list,
						  const char      *base_dir,
						  const char      *dest_dir,
						  gboolean         update,
						  const char      *password,
						  gboolean         encrypt_header,
						  FrCompression    compression,
						  guint            volume_size);
void        fr_archive_add_dropped_items         (FrArchive       *archive,
						  GList           *item_list,
						  const char      *base_dir,
						  const char      *dest_dir,
						  gboolean         update,
						  const char      *password,
						  gboolean         encrypt_header,
						  FrCompression    compression,
						  guint            volume_size);
void        fr_archive_test                      (FrArchive       *archive,
						  const char      *password);

/* utilities */

gboolean    uri_is_archive                       (const char      *uri);

#endif /* FR_ARCHIVE_H */