[gnome-autoar] extractor: Add autoar_extractor_set_passphrase function
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-autoar] extractor: Add autoar_extractor_set_passphrase function
- Date: Mon, 27 Jun 2022 11:40:49 +0000 (UTC)
commit 15e057226ccaf217bb1ca1e3e5a8ac18e97d1fe5
Author: Sergio Costas Rodriguez <sergio costas canonical com>
Date: Tue Jun 14 10:44:21 2022 +0200
extractor: Add autoar_extractor_set_passphrase function
To manage passphrase-protected files, the extractor sends the
`request-passphrase` signal and expects to receive the passphrase as
the signal's return value. That's too complicated for some use cases
and is not possible with asynchronous API currently. Let's add an
extra method that allows to set the passphrase.
Relates: https://gitlab.gnome.org/GNOME/gnome-autoar/-/issues/42
gnome-autoar/autoar-extractor.c | 19 +++++++++++++++++++
gnome-autoar/autoar-extractor.h | 2 ++
2 files changed, 21 insertions(+)
---
diff --git a/gnome-autoar/autoar-extractor.c b/gnome-autoar/autoar-extractor.c
index f139116..9f846b7 100644
--- a/gnome-autoar/autoar-extractor.c
+++ b/gnome-autoar/autoar-extractor.c
@@ -2132,6 +2132,25 @@ autoar_extractor_start_async_thread (GTask *task,
g_object_unref (task);
}
+/**
+ * autoar_extractor_set_passphrase:
+ * @self: an #AutoarExtractor object
+ * @password: a string with the passphrase to use
+ *
+ * Sets a passphrase to use if the file to decompress is passphrase-protected.
+ **/
+void
+autoar_extractor_set_passphrase (AutoarExtractor *self,
+ const gchar *passphrase)
+{
+ g_return_if_fail (AUTOAR_IS_EXTRACTOR (self));
+ g_return_if_fail (passphrase != NULL);
+
+ self->passphrase_requested = TRUE;
+
+ g_free (self->passphrase);
+ self->passphrase = g_strdup (passphrase);
+}
/**
* autoar_extractor_start_async:
diff --git a/gnome-autoar/autoar-extractor.h b/gnome-autoar/autoar-extractor.h
index 77f5e91..4df822e 100644
--- a/gnome-autoar/autoar-extractor.h
+++ b/gnome-autoar/autoar-extractor.h
@@ -74,6 +74,8 @@ void autoar_extractor_set_delete_after_extraction (AutoarExtractor *
gboolean delete_after_extraction);
void autoar_extractor_set_notify_interval (AutoarExtractor *self,
gint64 notify_interval);
+void autoar_extractor_set_passphrase (AutoarExtractor *self,
+ const gchar *passphrase);
typedef enum {
AUTOAR_CONFLICT_UNHANDLED = 0,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]