diff options
author | eerielili <lionel@les-miquelots.net> | 2024-08-25 13:32:38 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-25 13:32:38 +0000 |
commit | 45755727db79a2935376d24e7bde7eadb0f2f7ca (patch) | |
tree | 73715da99c9d980079df6f2d561822364655e04d /xmpp-vala/src/core/stanza_reader.vala | |
parent | 62cdea3a5e701c04f3a7fd9d6b5f48e28fef1f72 (diff) | |
parent | 51252f74c94c17d56aa75534652bdc5d43a504cb (diff) | |
download | dino-45755727db79a2935376d24e7bde7eadb0f2f7ca.tar.gz dino-45755727db79a2935376d24e7bde7eadb0f2f7ca.zip |
Merge branch 'master' into add-yourselfadd-yourself
Diffstat (limited to 'xmpp-vala/src/core/stanza_reader.vala')
-rw-r--r-- | xmpp-vala/src/core/stanza_reader.vala | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/xmpp-vala/src/core/stanza_reader.vala b/xmpp-vala/src/core/stanza_reader.vala index 17f0b7b0..349476ec 100644 --- a/xmpp-vala/src/core/stanza_reader.vala +++ b/xmpp-vala/src/core/stanza_reader.vala @@ -13,7 +13,7 @@ public class StanzaReader { private uint8[] buffer; private int buffer_fill = 0; private int buffer_pos = 0; - private Cancellable cancellable = new Cancellable(); + private Cancellable? cancellable; private NamespaceState ns_state = new NamespaceState(); @@ -26,19 +26,16 @@ public class StanzaReader { this.for_buffer(s.data); } - public StanzaReader.for_stream(InputStream input) { + public StanzaReader.for_stream(InputStream input, Cancellable? cancellable = null) { this.input = input; + this.cancellable = cancellable; buffer = new uint8[BUFFER_MAX]; } - public void cancel() { - cancellable.cancel(); - } - private async void update_buffer() throws IOError { InputStream? input = this.input; if (input == null) throw new IOError.CLOSED("No input stream specified and end of buffer reached."); - if (cancellable.is_cancelled()) throw new IOError.CANCELLED("Input stream is canceled."); + if (cancellable != null && cancellable.is_cancelled()) throw new IOError.CANCELLED("Input stream is canceled."); buffer_fill = (int) yield ((!)input).read_async(buffer, GLib.Priority.DEFAULT, cancellable); if (buffer_fill == 0) throw new IOError.CLOSED("End of input stream reached."); buffer_pos = 0; |