aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/core/stanza_reader.vala
diff options
context:
space:
mode:
Diffstat (limited to 'xmpp-vala/src/core/stanza_reader.vala')
-rw-r--r--xmpp-vala/src/core/stanza_reader.vala11
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;