--- a/dodo/dodoinputstream.c Sun Aug 06 02:07:37 2023 -0500
+++ b/dodo/dodoinputstream.c Sun Aug 06 04:27:40 2023 -0500
@@ -21,6 +21,12 @@
const gsize DODO_INPUT_STREAM_BUFFER_LEN = 4096;
+static guint signals[N_SIGNALS]; struct _DodoInputStream {
@@ -36,9 +42,10 @@
*****************************************************************************/
-dodo_input_stream_close(G_GNUC_UNUSED DodoInputStream *stream,
+dodo_input_stream_close(DodoInputStream *stream, G_GNUC_UNUSED GError **error)
+ g_signal_emit(stream, signals[SIG_CLOSED], 0); @@ -207,7 +214,24 @@
-dodo_input_stream_class_init(G_GNUC_UNUSED DodoInputStreamClass *klass) {
+dodo_input_stream_class_init(DodoInputStreamClass *klass) { + * DodoInputStream::closed: + * Emitted when the input stream is closed. + signals[SIG_CLOSED] = g_signal_new_class_handler( + G_OBJECT_CLASS_TYPE(klass), /******************************************************************************
--- a/dodo/tests/testinputstream.c Sun Aug 06 02:07:37 2023 -0500
+++ b/dodo/tests/testinputstream.c Sun Aug 06 04:27:40 2023 -0500
@@ -22,10 +22,26 @@
/******************************************************************************
*****************************************************************************/
+ * test_dodo_input_stream_closed_cb: (skip) + * @stream: The instance. + * @data: a pointer to a guint to be incremented. + * Increments @data to verify how many times the [signal@InputStream::closed] + * signal has been called. +dodo_input_stream_stream_closed_cb(G_GNUC_UNUSED DodoInputStream *stream, + *counter = *counter + 1; * test_dodo_connection_timeout_cb: (skip)
- * data: The main loop to quit.
+ * @data: The main loop to quit. * Used for callbacks for timing out the main loops when running tests. If this
* is called, it will assert that it was reached and cause the test to fail.
@@ -63,10 +79,14 @@
"<stream:stream from=\"juliet@im.example.com\" "
"to=\"im.example.com\" id=\"t7AMCin9zjMNwQKDnplntZPIDEI=\" "
"version=\"1.0\" xml:lang=\"en\" xmlns=\"jabber:client\" "
- "xmlns:stream=\"http://etherx.jabber.org/streams\">";
+ "xmlns:stream=\"http://etherx.jabber.org/streams\">" const char *value = NULL;
stream = dodo_input_stream_new();
+ g_signal_connect(stream, "closed", + G_CALLBACK(dodo_input_stream_stream_closed_cb), &counter); input = g_memory_input_stream_new_from_data(input_data, -1, NULL);
@@ -98,6 +118,9 @@
value = dodo_stream_get_language(DODO_STREAM(stream));
g_assert_cmpstr(value, ==, "en");
+ /* Make sure the close signal was emitted. */ + g_assert_cmpuint(counter, ==, 1);