xeme/xemeinputstream.h

Wed, 22 Jan 2025 22:13:20 -0600

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Wed, 22 Jan 2025 22:13:20 -0600
changeset 51
1294ebed86cf
parent 47
0822a5847e59
permissions
-rw-r--r--

Add a library version

Testing Done:
Compiled and confirmed the shared library had a version, and symlinks were installed.

Bugs closed: XEME-2

Reviewed at https://reviews.imfreedom.org/r/3781/

/*
 * Copyright (C) 2023-2024 Xeme 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 XEME_INPUT_STREAM_H
#define XEME_INPUT_STREAM_H

#include <glib.h>
#include <glib-object.h>

#include <gio/gio.h>

#include <xeme/xememessage.h>
#include <xeme/xemeoutputstream.h>
#include <xeme/xemestream.h>
#include <xeme/xemeversion.h>

G_BEGIN_DECLS

/**
 * XemeInputStream:
 *
 * An object that handles the incoming stream from a remote connection.
 *
 * Since: 0.1
 */

#define XEME_TYPE_INPUT_STREAM (xeme_input_stream_get_type())

XEME_AVAILABLE_IN_0_1
G_DECLARE_DERIVABLE_TYPE(XemeInputStream, xeme_input_stream, XEME, INPUT_STREAM, XemeStream)

struct _XemeInputStreamClass {
	/*< private >*/
	XemeStreamClass parent;

	/*< private >*/
	gpointer reserved[8];
};

/**
 * xeme_input_stream_new:
 *
 * Creates a new input stream.
 *
 * Returns: (transfer full): The new instance.
 *
 * Since: 0.1
 */
XEME_AVAILABLE_IN_0_1
XemeInputStream *xeme_input_stream_new(void);

/**
 * xeme_input_stream_start:
 * @stream: The instance.
 * @input: (transfer none): A [class@Gio.InputStream] for reading data from the
 *         server.
 * @output: (transfer none): The output stream for sending data.
 * @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
 */
XEME_AVAILABLE_IN_0_1
gboolean xeme_input_stream_start(XemeInputStream *stream, GInputStream *input, XemeOutputStream *output, GError **error);

/**
 * xeme_input_stream_restart_requested:
 * @stream: The instance.
 *
 * Emits the [signal@InputStream::restart-requested] signal.
 *
 * This should be called when the remote side has requested that the output
 * stream should be restarted. This typically happens during feature
 * negotiation during the initial connection.
 *
 * This signal allows who ever is managing the streams to call
 * [method@OutputStream.restart] on the output stream.
 *
 * Since: 0.1
 */
XEME_AVAILABLE_IN_0_1
void xeme_input_stream_restart_requested(XemeInputStream *stream);

/**
 * xeme_input_stream_get_output_stream:
 * @stream: The instance.
 *
 * Gets the [class@OutputStream] that should be used for requests and responses
 * with the remote end of the connection.
 *
 * Note: this will only be set after [method@InputStream.start] has been
 * called.
 *
 * Returns: (transfer none) (nullable): The output stream if set, otherwise
 *          %NULL.
 *
 * Since: 0.1
 */
XEME_AVAILABLE_IN_0_1
XemeOutputStream *xeme_input_stream_get_output_stream(XemeInputStream *stream);

G_END_DECLS

#endif /* XEME_INPUT_STREAM_H */

mercurial