--- a/dodo/dodoinputstream.c Sun Jul 09 01:58:53 2023 -0500
+++ b/dodo/dodoinputstream.c Sun Jul 09 02:38:13 2023 -0500
@@ -30,7 +30,7 @@
GMarkupParseContext *context;
-G_DEFINE_TYPE(DodoInputStream, dodo_input_stream, G_TYPE_OBJECT)
+G_DEFINE_TYPE(DodoInputStream, dodo_input_stream, DODO_TYPE_STREAM) /******************************************************************************
@@ -103,7 +103,7 @@
const char *version = NULL;
const char *xml_lang = NULL;
const char *xmlns = NULL;
- const char *xmlns_server = NULL;
+ const char *xmlns_stream = NULL; ret = g_markup_collect_attributes(
element_name, attribute_names, attribute_values, error,
@@ -113,7 +113,7 @@
G_MARKUP_COLLECT_STRING, "version", &version,
G_MARKUP_COLLECT_STRING | G_MARKUP_COLLECT_OPTIONAL, "xml:lang", &xml_lang,
G_MARKUP_COLLECT_STRING | G_MARKUP_COLLECT_OPTIONAL, "xmlns", &xmlns,
- G_MARKUP_COLLECT_STRING | G_MARKUP_COLLECT_OPTIONAL, "xmlns:server", &xmlns_server,
+ G_MARKUP_COLLECT_STRING | G_MARKUP_COLLECT_OPTIONAL, "xmlns:stream", &xmlns_stream, G_MARKUP_COLLECT_INVALID);
@@ -145,10 +145,10 @@
- if(!dodo_str_equal(xmlns_server, DODO_STREAM_XMLNS_STREAM)) {
+ if(!dodo_str_equal(xmlns_stream, DODO_STREAM_XMLNS_STREAM)) { g_set_error(error, DODO_DOMAIN, 0,
"got xmlns:stream='%s' but was expecting '%s'",
- xmlns_server, DODO_STREAM_XMLNS_STREAM);
+ xmlns_stream, DODO_STREAM_XMLNS_STREAM); --- a/dodo/tests/meson.build Sun Jul 09 01:58:53 2023 -0500
+++ b/dodo/tests/meson.build Sun Jul 09 02:38:13 2023 -0500
@@ -1,4 +1,5 @@
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dodo/tests/testinputstream.c Sun Jul 09 02:38:13 2023 -0500
@@ -0,0 +1,117 @@
+ * 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/>. +/****************************************************************************** + *****************************************************************************/ + * test_dodo_connection_timeout_cb: (skip) + * 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. + * Returns: G_SOURCE_REMOVE to not be called again. +test_dodo_input_stream_timeout_cb(gpointer data) { + g_main_loop_quit(data); + g_assert_not_reached(); + return G_SOURCE_REMOVE; +test_dodo_input_stream_quit_cb(gpointer data) { + g_main_loop_quit(data); + return G_SOURCE_REMOVE; +/****************************************************************************** + *****************************************************************************/ +test_dodo_input_stream_start(void) { + DodoInputStream *stream = NULL; + GMainLoop *loop = NULL; + GInputStream *input = NULL; + const char *input_data = "" \ + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<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\">"; + const char *value = NULL; + stream = dodo_input_stream_new(); + input = g_memory_input_stream_new_from_data(input_data, -1, NULL); + ret = dodo_input_stream_start(stream, input, &error); + g_assert_no_error(error); + /* Create our main loop and add some timeouts and stuff. */ + loop = g_main_loop_new(NULL, FALSE); + g_timeout_add(2, test_dodo_input_stream_quit_cb, loop); + g_timeout_add(100, test_dodo_input_stream_timeout_cb, loop); + /* If we made it here, the quit cb got called, so verify everything. */ + value = dodo_stream_get_from(DODO_STREAM(stream)); + g_assert_cmpstr(value, ==, "juliet@im.example.com"); + value = dodo_stream_get_to(DODO_STREAM(stream)); + g_assert_cmpstr(value, ==, "im.example.com"); + value = dodo_stream_get_id(DODO_STREAM(stream)); + g_assert_cmpstr(value, ==, "t7AMCin9zjMNwQKDnplntZPIDEI="); + value = dodo_stream_get_version(DODO_STREAM(stream)); + g_assert_cmpstr(value, ==, "1.0"); + value = dodo_stream_get_language(DODO_STREAM(stream)); + g_assert_cmpstr(value, ==, "en"); + g_clear_object(&input); + g_clear_object(&stream); +/****************************************************************************** + *****************************************************************************/ +main(int argc, char *argv[]) { + g_test_init(&argc, &argv, NULL); + g_test_add_func("/dodo/input_stream/start", + test_dodo_input_stream_start);