diff options
author | Bastien Nocera <hadess@hadess.net> | 2020-02-27 16:57:18 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2020-02-27 18:53:16 +0100 |
commit | 6e160da7b3fd4fcf053d7872af1ba3ddcd2aa12a (patch) | |
tree | 3bdf98cca8ecb4ae4909589e872e60866754f249 | |
parent | 26b8e7fb6913ea44d0caccb4a6c164aadb5e525c (diff) | |
download | totem-pl-parser-6e160da7b3fd4fcf053d7872af1ba3ddcd2aa12a.tar.gz |
plparser: Make totem_pl_parser_write_string() cancellable
-rw-r--r-- | plparse/totem-pl-parser-lines.c | 6 | ||||
-rw-r--r-- | plparse/totem-pl-parser-pls.c | 10 | ||||
-rw-r--r-- | plparse/totem-pl-parser-private.h | 1 | ||||
-rw-r--r-- | plparse/totem-pl-parser-xspf.c | 12 | ||||
-rw-r--r-- | plparse/totem-pl-parser.c | 8 |
5 files changed, 21 insertions, 16 deletions
diff --git a/plparse/totem-pl-parser-lines.c b/plparse/totem-pl-parser-lines.c index 7bbf586..89e4408 100644 --- a/plparse/totem-pl-parser-lines.c +++ b/plparse/totem-pl-parser-lines.c @@ -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) diff --git a/plparse/totem-pl-parser-pls.c b/plparse/totem-pl-parser-pls.c index 742be25..06eb402 100644 --- a/plparse/totem-pl-parser-pls.c +++ b/plparse/totem-pl-parser-pls.c @@ -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); diff --git a/plparse/totem-pl-parser-private.h b/plparse/totem-pl-parser-private.h index d868e9b..b9fc53e 100644 --- a/plparse/totem-pl-parser-private.h +++ b/plparse/totem-pl-parser-private.h @@ -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, diff --git a/plparse/totem-pl-parser-xspf.c b/plparse/totem-pl-parser-xspf.c index bb4c722..f30883b 100644 --- a/plparse/totem-pl-parser-xspf.c +++ b/plparse/totem-pl-parser-xspf.c @@ -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); diff --git a/plparse/totem-pl-parser.c b/plparse/totem-pl-parser.c index 0d7f932..282e65a 100644 --- a/plparse/totem-pl-parser.c +++ b/plparse/totem-pl-parser.c @@ -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); } /** |