queuedoutputstream: Refactor to behave better with the rest of Gio
PurpleQueuedOutputStream uses purple_queued_output_stream_push_bytes()
in order to queue bytes to be flushed. This requires consuming code to
call flush when it's not already flushing, and doesn't allow other
GOutputStream operations to behave well in combination with the
queued operations.
This patch refactors PurpleQueuedOutputStream to behave more like other
GOutputStream operations. It adds
purple_queued_output_stream_push_bytes_async(), which has the same
signature as the write_async functions. This way, if the there are
already queued bytes, it will send the new bytes when their turn
has come, and if not, it will start sending the new bytes immediately.
No need to flush. If a non-queued operation is attempted, it will
behave the same as if any other operation is pending. If a non-queued
operation is pending and a queued operation is attempted, it will
behave the same as a non-queued operation.
Now that the callback is called per async operation, if there's a
fatal error, all remaining queued operations will likely return
this same error. purple_queued_output_stream_clear_queue() was added
to handle this issue. If a fatal error occurs, call
purple_queued_output_stream_clear_queue() in
purple_queued_output_stream_push_bytes_async()'s callback in order
to clear the queue and avoid excessive errors returning.