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
This commit is contained in:
parent
ed46390bbc
commit
a6dfe20348
@ -560,6 +560,29 @@ shell_get_event_state (ClutterEvent *event)
|
|||||||
return state & CLUTTER_MODIFIER_MASK;
|
return state & CLUTTER_MODIFIER_MASK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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:
|
* shell_write_string_to_stream:
|
||||||
* @stream: a #GOutputStream
|
* @stream: a #GOutputStream
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
#include <clutter/clutter.h>
|
#include <clutter/clutter.h>
|
||||||
|
#include <libsoup/soup.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
@ -25,6 +26,10 @@ char *shell_util_format_date (const char *format,
|
|||||||
ClutterModifierType
|
ClutterModifierType
|
||||||
shell_get_event_state (ClutterEvent *event);
|
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,
|
gboolean shell_write_string_to_stream (GOutputStream *stream,
|
||||||
const char *str,
|
const char *str,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
Loading…
Reference in New Issue
Block a user