xeme/xeme

Add a simple unit test for the input stream and fix a few issues
/*
* Copyright (C) 2023 Dodo Developers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <https://www.gnu.org/licenses/>.
*/
#ifndef DODO_INPUT_STREAM_H
#define DODO_INPUT_STREAM_H
#include <glib.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <dodo/dodostream.h>
G_BEGIN_DECLS
#define DODO_TYPE_INPUT_STREAM (dodo_input_stream_get_type())
G_DECLARE_FINAL_TYPE(DodoInputStream, dodo_input_stream, DODO, INPUT_STREAM, DodoStream)
/**
* dodo_input_stream_new:
*
* Creates a new input stream.
*
* > Note: this is typically only necessary for [class@Client].
*
* Returns: (transfer full): The new instance.
*
* Since: 0.1.0
*/
DodoInputStream *dodo_input_stream_new(void);
/**
* dodo_input_stream_start:
* @stream: The instance.
* @input: (transfer none): A [class@Gio.InputStream] for reading data from the
* server.
* @error: (nullable): A return address for a #GError.
*
* Starts processing @input as an incoming XMPP stream. It is the
* responsibility of the caller to establish any necessary connections as this
* just processes the raw XMPP data from @input.
*
* Input is handled asynchronously so this function will always return
* immediately. If setup and processing was successful, %TRUE will be returned,
* otherwise %FALSE will be returned with @error set.
*
* Returns: %TRUE on success, otherwise %FALSE with @error set.
*
* Since: 0.1.0
*/
gboolean dodo_input_stream_start(DodoInputStream *stream, GInputStream *input, GError **error);
G_END_DECLS
#endif /* DODO_INPUT_STREAM_H */