From 93431e0eeb2bfa566ce1d5240ce9c75e976d0c07 Mon Sep 17 00:00:00 2001 From: Ting-Wei Lan Date: Tue, 30 Jul 2013 17:14:59 +0800 Subject: Add some missing definitions and functions --- autoarchive/autoar-create.c | 84 ++++++++++++++++++++++++++++++++++++++++++--- autoarchive/autoar-create.h | 7 ++-- autoarchive/autoar-pref.h | 4 +-- 3 files changed, 87 insertions(+), 8 deletions(-) diff --git a/autoarchive/autoar-create.c b/autoarchive/autoar-create.c index 514afbe99..4b946bd43 100644 --- a/autoarchive/autoar-create.c +++ b/autoarchive/autoar-create.c @@ -30,6 +30,7 @@ #include #include +#include G_DEFINE_TYPE (AutoarCreate, autoar_create, G_TYPE_OBJECT) @@ -43,6 +44,7 @@ struct _AutoarCreatePrivate char **source; char *output; + guint64 size; /* This field is currently unused */ guint64 completed_size; guint files; @@ -70,6 +72,7 @@ enum PROP_0, PROP_SOURCE, PROP_OUTPUT, + PROP_SIZE, /* This property is currently unused */ PROP_COMPLETED_SIZE, PROP_FILES, PROP_COMPLETED_FILES @@ -102,6 +105,8 @@ autoar_create_get_property (GObject *object, case PROP_OUTPUT: g_value_set_string (value, priv->output); break; + case PROP_SIZE: + g_value_set_uint64 (value, priv->size); case PROP_COMPLETED_SIZE: g_value_set_uint64 (value, priv->completed_size); break; @@ -132,6 +137,9 @@ autoar_create_set_property (GObject *object, priv = arcreate->priv; switch (property_id) { + case PROP_SIZE: + autoar_create_set_size (arcreate, g_value_get_uint64 (value)); + break; case PROP_COMPLETED_SIZE: autoar_create_set_completed_size (arcreate, g_value_get_uint64 (value)); break; @@ -170,6 +178,13 @@ autoar_create_get_output (AutoarCreate *arcreate) return arcreate->priv->output; } +guint64 +autoar_create_get_size (AutoarCreate *arcreate) +{ + g_return_val_if_fail (AUTOAR_IS_CREATE (arcreate), 0); + return arcreate->priv->size; +} + guint64 autoar_create_get_completed_size (AutoarCreate *arcreate) { @@ -191,6 +206,14 @@ autoar_create_get_completed_files (AutoarCreate *arcreate) return arcreate->priv->completed_files; } +void +autoar_create_set_size (AutoarCreate *arcreate, + guint64 size) +{ + g_return_if_fail (AUTOAR_IS_CREATE (arcreate)); + arcreate->priv->size = size; +} + void autoar_create_set_completed_size (AutoarCreate *arcreate, guint64 completed_size) @@ -310,6 +333,16 @@ autoar_create_class_init (AutoarCreateClass *klass) G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)); + g_object_class_install_property (object_class, PROP_SIZE, + g_param_spec_uint64 ("size", + "Size", + "Unused property", + 0, G_MAXUINT64, 0, + G_PARAM_READWRITE | + G_PARAM_STATIC_NAME | + G_PARAM_STATIC_NICK | + G_PARAM_STATIC_BLURB)); + g_object_class_install_property (object_class, PROP_COMPLETED_SIZE, g_param_spec_uint64 ("completed-size", "Read file size", @@ -412,11 +445,11 @@ autoar_create_init (AutoarCreate *arcreate) } AutoarCreate* -autoar_create_new (const char **source, - const char *output, - AutoarPref *arpref) +autoar_create_newv (AutoarPref *arpref, + const char *output, + const char **source) { - AutoarCreate* arcreate; + AutoarCreate *arcreate; g_return_val_if_fail (source != NULL, NULL); g_return_val_if_fail (output != NULL, NULL); @@ -429,3 +462,46 @@ autoar_create_new (const char **source, return arcreate; } + +AutoarCreate* +autoar_create_new (AutoarPref *arpref, + const char *output, + ...) +{ + AutoarCreate *arcreate; + char *str; + va_list ap; + GPtrArray *strv; + + va_start (ap, output); + strv = g_ptr_array_new_with_free_func (g_free); + while ((str = va_arg (ap, char*)) != NULL) { + g_ptr_array_add (strv, str); + } + g_ptr_array_add (strv, NULL); + va_end (ap); + + arcreate = autoar_create_newv (arpref, output, (const char**)(strv->pdata)); + g_ptr_array_unref (strv); + return arcreate; +} + +static void +autoar_create_run (AutoarCreate *arcreate, + gboolean in_thread) +{ + struct archive *a; + struct archive_entry *entry; + +} + +void +autoar_create_start (AutoarCreate *arcreate) +{ + autoar_create_run (arcreate, FALSE); +} + +void +autoar_create_start_async (AutoarCreate *arcreate) +{ +} diff --git a/autoarchive/autoar-create.h b/autoarchive/autoar-create.h index 682a1887e..3c37945b3 100644 --- a/autoarchive/autoar-create.h +++ b/autoarchive/autoar-create.h @@ -67,9 +67,12 @@ struct _AutoarCreateClass GType autoar_create_get_type (void) G_GNUC_CONST; -AutoarCreate *autoar_create_new (const char **source, +AutoarCreate* autoar_create_new (AutoarPref *arpref, + const char *output, + ...); +AutoarCreate* autoar_create_newv (AutoarPref *arpref, const char *output, - AutoarPref *arpref); + const char **source); void autoar_create_start (AutoarCreate *arcreate); void autoar_create_start_async (AutoarCreate *arcreate); diff --git a/autoarchive/autoar-pref.h b/autoarchive/autoar-pref.h index b256ac059..a935ad324 100644 --- a/autoarchive/autoar-pref.h +++ b/autoarchive/autoar-pref.h @@ -35,7 +35,7 @@ G_BEGIN_DECLS typedef enum { AUTOAR_PREF_FORMAT_0, /*< skip >*/ - AUTOAR_PREF_FORMAT_ZIP, /* .zip */ + AUTOAR_PREF_FORMAT_ZIP = 1, /* .zip */ AUTOAR_PREF_FORMAT_TAR, /* .tar, pax_restricted */ AUTOAR_PREF_FORMAT_CPIO, /* .cpio, odc */ AUTOAR_PREF_FORMAT_7ZIP, /* .7z */ @@ -52,7 +52,7 @@ typedef enum { typedef enum { AUTOAR_PREF_FILTER_0, /*< skip >*/ - AUTOAR_PREF_FILTER_NONE, + AUTOAR_PREF_FILTER_NONE = 1, AUTOAR_PREF_FILTER_COMPRESS, /* .Z */ AUTOAR_PREF_FILTER_GZIP, /* .gz */ AUTOAR_PREF_FILTER_BZIP2, /* .bz2 */ -- cgit v1.2.3