[gcab] Add simpler variant of API using multiple callbacks



commit 972e123afdc2144c117e4d96048d4541342e180a
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date:   Fri Jan 18 00:49:23 2013 +0100

    Add simpler variant of API using multiple callbacks
    
    Vala doesn't know how to deal well with multiple callback functions

 libgcab/gcab-cabinet.c |   51 ++++++++++++++++++++++++++++++++++++++++++++++++
 libgcab/gcab-cabinet.h |   12 +++++++++++
 2 files changed, 63 insertions(+), 0 deletions(-)
---
diff --git a/libgcab/gcab-cabinet.c b/libgcab/gcab-cabinet.c
index 757c7bd..ef9b4d0 100644
--- a/libgcab/gcab-cabinet.c
+++ b/libgcab/gcab-cabinet.c
@@ -266,6 +266,31 @@ end:
 }
 
 /**
+ * gcab_cabinet_write_simple:
+ * @cabinet: a #GCabCabinet
+ * @stream: a #GOutputStream also #GSeekable
+ * @file_callback: (allow-none) (scope call) (closure user_data): report current file being saved
+ * @user_data: (closure): user data to pass to callbacks
+ * @cancellable: (allow-none): optional #GCancellable object,
+ *     %NULL to ignore
+ * @error: (allow-none): #GError to set on error, or %NULL
+ *
+ * Save @cabinet to the output stream @out. @out must be a #GSeekable.
+ *
+ * Returns: %TRUE on success.
+ **/
+gboolean
+gcab_cabinet_write_simple (GCabCabinet *self,
+                           GOutputStream *out,
+                           GCabFileCallback file_callback,
+                           gpointer user_data,
+                           GCancellable *cancellable,
+                           GError **error)
+{
+    return gcab_cabinet_write (self, out, file_callback, NULL, user_data, cancellable, error);
+}
+
+/**
  * gcab_cabinet_new:
  *
  * Returns: a new #GCabCabinet
@@ -398,3 +423,29 @@ gcab_cabinet_extract (GCabCabinet *self,
 end:
     return success;
 }
+
+/**
+ * gcab_cabinet_extract_simple:
+ * @cabinet: a #GCabCabinet
+ * @path: the path to extract files
+ * @file_callback: (allow-none) (scope call) (closure user_data): an optionnal #GCabFile callback,
+ *     return %FALSE to filter out or skip files.
+ * @user_data: (closure): callback data
+ * @cancellable: (allow-none): optional #GCancellable object,
+ *     %NULL to ignore
+ * @error: (allow-none): #GError to set on error, or %NULL
+ *
+ * Extract files to given path.
+ *
+ * Returns: %TRUE on success.
+ **/
+gboolean
+gcab_cabinet_extract_simple (GCabCabinet *cabinet,
+                             GFile *path,
+                             GCabFileCallback file_callback,
+                             gpointer user_data,
+                             GCancellable *cancellable,
+                             GError **error)
+{
+    return gcab_cabinet_extract (cabinet, path, file_callback, NULL, user_data, cancellable, error);
+}
diff --git a/libgcab/gcab-cabinet.h b/libgcab/gcab-cabinet.h
index 066645f..8fdf5d5 100644
--- a/libgcab/gcab-cabinet.h
+++ b/libgcab/gcab-cabinet.h
@@ -67,6 +67,12 @@ gboolean           gcab_cabinet_write         (GCabCabinet *cabinet,
                                                gpointer user_data,
                                                GCancellable *cancellable,
                                                GError **error);
+gboolean           gcab_cabinet_write_simple  (GCabCabinet *cabinet,
+                                               GOutputStream *stream,
+                                               GCabFileCallback file_callback,
+                                               gpointer user_data,
+                                               GCancellable *cancellable,
+                                               GError **error);
 gboolean           gcab_cabinet_extract       (GCabCabinet *cabinet,
                                                GFile *path,
                                                GCabFileCallback file_callback,
@@ -74,6 +80,12 @@ gboolean           gcab_cabinet_extract       (GCabCabinet *cabinet,
                                                gpointer user_data,
                                                GCancellable *cancellable,
                                                GError **error);
+gboolean           gcab_cabinet_extract_simple(GCabCabinet *cabinet,
+                                               GFile *path,
+                                               GCabFileCallback file_callback,
+                                               gpointer user_data,
+                                               GCancellable *cancellable,
+                                               GError **error);
 
 G_END_DECLS
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]