Commit 94c91a90 authored by Kyle Evans's avatar Kyle Evans
Browse files

Use GSeekable to pick out attachments



This is an alternative to loading the entire MMS payload blob and
picking out the attachments from main memory.
Signed-off-by: Kyle Evans's avatarKyle Evans <kvans32@gmail.com>
parent 389ccaba
......@@ -758,8 +758,8 @@ pur_mmsd_receive_message (GVariant *message_t)
GFile *container = NULL;
GFile *savepath;
char *contents;
gsize length, written = 0;
GFileInputStream *mms;
GSeekable *seek;
gchar *tag;
g_autoptr(GError) error = NULL;
......@@ -772,12 +772,8 @@ pur_mmsd_receive_message (GVariant *message_t)
if (!container) {
container = g_file_new_for_path (containerpath);
g_file_load_contents (container,
NULL,
&contents,
&length,
NULL,
&error);
mms = g_file_read (container, NULL, NULL);
seek = G_SEEKABLE (mms);
const gchar *home = g_get_home_dir ();
tag = g_strconcat (date, sender, NULL);
......@@ -816,12 +812,15 @@ pur_mmsd_receive_message (GVariant *message_t)
break;
}
if (!g_output_stream_write_all (G_OUTPUT_STREAM(out),
contents + data,
size,
&written,
NULL,
&error)) {
g_seekable_seek (seek, data, G_SEEK_SET, NULL, &error);
GBytes *chunk =
g_input_stream_read_bytes (G_INPUT_STREAM(mms), size, NULL, &error);
if (!g_output_stream_write_bytes (G_OUTPUT_STREAM(out),
chunk,
NULL,
&error)) {
g_warning ("attachment not saved!");
g_warning ("%s", error->message);
......@@ -840,7 +839,6 @@ pur_mmsd_receive_message (GVariant *message_t)
g_free (uri);
}
g_free(contents);
g_object_unref(container);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment