Commit 6e160da7 authored by Bastien Nocera's avatar Bastien Nocera

plparser: Make totem_pl_parser_write_string() cancellable

parent 26b8e7fb
......@@ -100,7 +100,7 @@ totem_pl_parser_save_m3u (TotemPlParser *parser,
cr = dos_compatible ? "\r\n" : "\n";
buf = g_strdup_printf ("#EXTM3U%s", cr);
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, error);
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, cancellable, error);
g_free (buf);
if (success == FALSE)
return FALSE;
......@@ -135,7 +135,7 @@ totem_pl_parser_save_m3u (TotemPlParser *parser,
if (title) {
buf = g_strdup_printf (EXTINF",%s%s", title, cr);
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, error);
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, cancellable, error);
g_free (buf);
if (success == FALSE) {
g_free (title);
......@@ -163,7 +163,7 @@ totem_pl_parser_save_m3u (TotemPlParser *parser,
g_free (path2);
g_free (uri);
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, error);
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, cancellable, error);
g_free (buf);
if (success == FALSE)
......
......@@ -56,21 +56,21 @@ totem_pl_parser_save_pls (TotemPlParser *parser,
return FALSE;
buf = g_strdup ("[playlist]\n");
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, error);
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, cancellable, error);
g_free (buf);
if (success == FALSE)
return FALSE;
if (title != NULL) {
buf = g_strdup_printf ("X-GNOME-Title=%s\n", title);
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, error);
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, cancellable, error);
g_free (buf);
if (success == FALSE)
return FALSE;
}
buf = g_strdup_printf ("NumberOfEntries=%d\n", num_entries);
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, error);
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, cancellable, error);
g_free (buf);
if (success == FALSE)
return FALSE;
......@@ -111,7 +111,7 @@ totem_pl_parser_save_pls (TotemPlParser *parser,
g_free (relative);
g_free (uri);
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, error);
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, cancellable, error);
g_free (buf);
if (success == FALSE) {
......@@ -124,7 +124,7 @@ totem_pl_parser_save_pls (TotemPlParser *parser,
}
buf = g_strdup_printf ("Title%d=%s\n", i, entry_title);
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, error);
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, cancellable, error);
g_free (buf);
g_free (entry_title);
......
......@@ -131,6 +131,7 @@ gboolean totem_pl_parser_scheme_is_ignored (TotemPlParser *parser,
gboolean totem_pl_parser_line_is_empty (const char *line);
gboolean totem_pl_parser_write_string (GOutputStream *stream,
const char *buf,
GCancellable *cancellable,
GError **error);
gboolean totem_pl_parser_write_buffer (GOutputStream *stream,
const char *buf,
......
......@@ -115,7 +115,7 @@ totem_pl_parser_save_xspf (TotemPlParser *parser,
buf = g_strdup_printf ("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<playlist version=\"1\" xmlns=\"http://xspf.org/ns/0/\">\n"
" <trackList>\n");
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, error);
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, cancellable, error);
g_free (buf);
if (success == FALSE)
return FALSE;
......@@ -145,7 +145,7 @@ totem_pl_parser_save_xspf (TotemPlParser *parser,
uri_escaped = g_markup_escape_text (relative ? relative : uri, -1);
buf = g_strdup_printf (" <track>\n"
" <location>%s</location>\n", uri_escaped);
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, error);
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, cancellable, error);
g_free (uri);
g_free (uri_escaped);
g_free (relative);
......@@ -193,7 +193,7 @@ totem_pl_parser_save_xspf (TotemPlParser *parser,
fields[i].element);
}
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, error);
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, cancellable, error);
g_free (buf);
g_free (escaped);
......@@ -205,12 +205,12 @@ totem_pl_parser_save_xspf (TotemPlParser *parser,
return FALSE;
if (wrote_ext)
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), " </extension>\n", error);
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), " </extension>\n", cancellable, error);
if (success == FALSE)
return FALSE;
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), " </track>\n", error);
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), " </track>\n", cancellable, error);
if (success == FALSE)
return FALSE;
......@@ -219,7 +219,7 @@ totem_pl_parser_save_xspf (TotemPlParser *parser,
buf = g_strdup_printf (" </trackList>\n"
"</playlist>");
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, error);
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, cancellable, error);
g_free (buf);
g_object_unref (stream);
......
......@@ -852,6 +852,7 @@ totem_pl_parser_line_is_empty (const char *line)
* totem_pl_parser_write_string:
* @handle: a #GFileOutputStream to an open file
* @buf: the string buffer to write out
* @cancellable: (allow-none): a #GCancellable, or %NULL
* @error: return location for a #GError, or %NULL
*
* Writes the string @buf out to the file specified by @handle.
......@@ -860,12 +861,15 @@ totem_pl_parser_line_is_empty (const char *line)
* Return value: %TRUE on success
**/
gboolean
totem_pl_parser_write_string (GOutputStream *stream, const char *buf, GError **error)
totem_pl_parser_write_string (GOutputStream *stream,
const char *buf,
GCancellable *cancellable,
GError **error)
{
guint len;
len = strlen (buf);
return totem_pl_parser_write_buffer (stream, buf, len, error);
return totem_pl_parser_write_buffer (stream, buf, len, cancellable, error);
}
/**
......
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