[gnome-shell] shell-util: Add a helper method for saving files from HTTP



commit a6dfe20348526572093c005f82a0d8f4e2d72a5c
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Mon Jun 27 20:17:27 2011 -0400

    shell-util: Add a helper method for saving files from HTTP
    
    Unfortunately, gjs cannot handle binary C strings directly from
    gobject-introspection. Add a simple workaround method in C to help
    us save random files from the web.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=653989

 src/shell-util.c |   23 +++++++++++++++++++++++
 src/shell-util.h |    5 +++++
 2 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/src/shell-util.c b/src/shell-util.c
index 3234faf..ef00f44 100644
--- a/src/shell-util.c
+++ b/src/shell-util.c
@@ -561,6 +561,29 @@ shell_get_event_state (ClutterEvent *event)
 }
 
 /**
+ * shell_write_soup_message_to_stream:
+ * @stream: a #GOutputStream
+ * @message: a #SoupMessage
+ * @error: location to store GError
+ *
+ * Write a string to a GOutputStream as binary data. This is a
+ * workaround for the lack of proper binary strings in GJS.
+ */
+void
+shell_write_soup_message_to_stream (GOutputStream *stream,
+                                    SoupMessage   *message,
+                                    GError       **error)
+{
+  SoupMessageBody *body;
+
+  body = message->response_body;
+
+  g_output_stream_write_all (stream,
+                             body->data, body->length,
+                             NULL, NULL, error);
+}
+
+/**
  * shell_write_string_to_stream:
  * @stream: a #GOutputStream
  * @str: a UTF-8 string to write to @stream
diff --git a/src/shell-util.h b/src/shell-util.h
index 7887f9e..1f431ff 100644
--- a/src/shell-util.h
+++ b/src/shell-util.h
@@ -5,6 +5,7 @@
 
 #include <gio/gio.h>
 #include <clutter/clutter.h>
+#include <libsoup/soup.h>
 
 G_BEGIN_DECLS
 
@@ -25,6 +26,10 @@ char    *shell_util_format_date                (const char       *format,
 ClutterModifierType
          shell_get_event_state                 (ClutterEvent     *event);
 
+void     shell_write_soup_message_to_stream    (GOutputStream    *stream,
+                                                SoupMessage      *message,
+                                                GError          **error);
+
 gboolean shell_write_string_to_stream          (GOutputStream    *stream,
                                                 const char       *str,
                                                 GError          **error);



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