From 2413442905e31f34cb0f77c9167003b3725760fe Mon Sep 17 00:00:00 2001 From: Marvin W Date: Sat, 3 Oct 2026 16:05:51 +0200 Subject: Drop supported for outdated dependency versions --- xmpp-vala/src/core/direct_tls_xmpp_stream.vala | 2 -- xmpp-vala/src/core/module_flag.vala | 10 ---------- 2 files changed, 12 deletions(-) (limited to 'xmpp-vala/src/core') diff --git a/xmpp-vala/src/core/direct_tls_xmpp_stream.vala b/xmpp-vala/src/core/direct_tls_xmpp_stream.vala index 2f159ab6..55488eb5 100644 --- a/xmpp-vala/src/core/direct_tls_xmpp_stream.vala +++ b/xmpp-vala/src/core/direct_tls_xmpp_stream.vala @@ -19,9 +19,7 @@ public class Xmpp.DirectTlsXmppStream : TlsXmppStream { debug("Connecting to %s:%i (tls)", host, port); IOStream? io_stream = yield client.connect_to_host_async(host, port, cancellable); TlsConnection tls_connection = TlsClientConnection.new(io_stream, new NetworkAddress(remote_name.to_string(), port)); -#if GLIB_2_60 tls_connection.set_advertised_protocols(ADVERTISED_PROTOCOLS); -#endif tls_connection.accept_certificate.connect(on_invalid_certificate); tls_connection.accept_certificate.connect((cert, flags) => on_invalid_cert.func(cert, flags)); reset_stream(tls_connection); diff --git a/xmpp-vala/src/core/module_flag.vala b/xmpp-vala/src/core/module_flag.vala index 76ae4dc1..95547852 100644 --- a/xmpp-vala/src/core/module_flag.vala +++ b/xmpp-vala/src/core/module_flag.vala @@ -10,12 +10,7 @@ namespace Xmpp { } public T? cast(XmppStreamFlag flag) { -#if VALA_0_56_11 - // We can't typecheck due to compiler bug - return (T) module; -#else return flag.get_type().is_a(typeof(T)) ? (T?) flag : null; -#endif } public bool matches(XmppStreamFlag module) { @@ -39,12 +34,7 @@ namespace Xmpp { } public T? cast(XmppStreamModule module) { -#if VALA_0_56_11 - // We can't typecheck due to compiler bug - return (T) module; -#else return module.get_type().is_a(typeof(T)) ? (T?) module : null; -#endif } public bool matches(XmppStreamModule module) { -- cgit v1.3 From 630b1368331ef0034b343bd2f00b116c8cd90391 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Sun, 4 Oct 2026 17:49:16 +0200 Subject: Fix some warnings --- .../omemo/ui/encryption_preferences_entry.vala | 4 + main/src/plugins/omemo/ui/manage_key_dialog.vala | 3 + main/src/ui/main_window.vala | 24 +++--- main/src/ui/util/data_forms.vala | 2 +- xmpp-vala/src/core/stanza_attribute.vala | 16 +++- xmpp-vala/src/core/stanza_node.vala | 92 ++++++++++++---------- xmpp-vala/src/core/stream_connect.vala | 10 ++- xmpp-vala/src/module/bookmarks_provider.vala | 8 +- xmpp-vala/src/module/iq/module.vala | 2 +- xmpp-vala/src/module/sasl.vala | 14 ++-- xmpp-vala/src/module/session.vala | 10 ++- xmpp-vala/src/module/xep/0004_data_forms.vala | 3 +- .../module/xep/0030_service_discovery/module.vala | 4 +- xmpp-vala/src/module/xep/0045_muc/module.vala | 24 +++--- xmpp-vala/src/module/xep/0048_bookmarks.vala | 10 +-- .../src/module/xep/0049_private_xml_storage.vala | 4 +- xmpp-vala/src/module/xep/0054_vcard/module.vala | 2 +- xmpp-vala/src/module/xep/0060_pubsub.vala | 10 +-- .../src/module/xep/0065_socks5_bytestreams.vala | 2 +- .../src/module/xep/0077_in_band_registration.vala | 6 +- .../src/module/xep/0082_date_time_profiles.vala | 4 +- xmpp-vala/src/module/xep/0084_user_avatars.vala | 2 +- .../src/module/xep/0166_jingle/component.vala | 12 ++- xmpp-vala/src/module/xep/0166_jingle/content.vala | 12 ++- .../src/module/xep/0166_jingle/jingle_flag.vala | 7 +- xmpp-vala/src/module/xep/0166_jingle/session.vala | 7 +- .../0176_jingle_ice_udp/transport_parameters.vala | 6 +- .../src/module/xep/0191_blocking_command.vala | 8 +- xmpp-vala/src/module/xep/0199_ping.vala | 2 +- .../xep/0215_external_service_discovery.vala | 2 +- .../src/module/xep/0234_jingle_file_transfer.vala | 2 +- .../module/xep/0260_jingle_socks5_bytestreams.vala | 10 ++- xmpp-vala/src/module/xep/0272_muji.vala | 7 +- xmpp-vala/src/module/xep/0280_message_carbons.vala | 12 ++- .../xep/0313_2_message_archive_management.vala | 4 +- .../xep/0313_message_archive_management.vala | 2 +- .../module/xep/0392_consistent_color/hsluv.vala | 6 +- xmpp-vala/src/module/xep/0402_bookmarks2.vala | 6 +- xmpp-vala/src/module/xep/0461_replies.vala | 1 - xmpp-vala/tests/color.vala | 6 +- xmpp-vala/tests/stanza.vala | 48 ++++++----- xmpp-vala/tests/testcase.vala | 13 ++- 42 files changed, 271 insertions(+), 158 deletions(-) (limited to 'xmpp-vala/src/core') diff --git a/main/src/plugins/omemo/ui/encryption_preferences_entry.vala b/main/src/plugins/omemo/ui/encryption_preferences_entry.vala index 55faecac..7f53a1b2 100644 --- a/main/src/plugins/omemo/ui/encryption_preferences_entry.vala +++ b/main/src/plugins/omemo/ui/encryption_preferences_entry.vala @@ -224,6 +224,10 @@ public class OmemoPreferencesWidget : Adw.PreferencesGroup { case TrustLevel.VERIFIED: trust_str = _("Verified"); break; + case TrustLevel.TRUSTED: + case TrustLevel.UNKNOWN: + default: + break; } action_row.add_suffix(new Label(trust_str)); diff --git a/main/src/plugins/omemo/ui/manage_key_dialog.vala b/main/src/plugins/omemo/ui/manage_key_dialog.vala index 65033999..59e6db24 100644 --- a/main/src/plugins/omemo/ui/manage_key_dialog.vala +++ b/main/src/plugins/omemo/ui/manage_key_dialog.vala @@ -141,6 +141,9 @@ public class ManageKeyDialog : Gtk.Dialog { main_desc_label.set_markup(_("This key is currently %s.").printf(""+_("rejected")+"")+" "+_("This means it cannot be used by %s to decipher your messages, and you won't see messages encrypted with it.").printf(@"$(device[db.identity_meta.address_name])")); main_action_list.append(accept_row); break; + case TrustLevel.UNKNOWN: + default: + break; } //Row clicked - go to appropriate screen diff --git a/main/src/ui/main_window.vala b/main/src/ui/main_window.vala index d2a23954..da6960ea 100644 --- a/main/src/ui/main_window.vala +++ b/main/src/ui/main_window.vala @@ -11,21 +11,21 @@ public class MainWindow : Adw.ApplicationWindow { public signal void conversation_selected(Conversation conversation); - [GtkChild] public Stack stack; - [GtkChild] public Adw.NavigationSplitView navigation_split_view; + [GtkChild] public unowned Stack stack; + [GtkChild] public unowned Adw.NavigationSplitView navigation_split_view; - [GtkChild] public MenuButton add_button; - [GtkChild] public MenuButton menu_button; + [GtkChild] public unowned MenuButton add_button; + [GtkChild] public unowned MenuButton menu_button; - [GtkChild] public Adw.HeaderBar conversation_headerbar; - [GtkChild] public Adw.WindowTitle conversation_window_title; + [GtkChild] public unowned Adw.HeaderBar conversation_headerbar; + [GtkChild] public unowned Adw.WindowTitle conversation_window_title; - [GtkChild] public ConversationView conversation_view; - [GtkChild] public ConversationSelector conversation_selector; - [GtkChild] public Adw.Flap search_flap; - [GtkChild] private Stack left_stack; - [GtkChild] private Stack right_stack; - [GtkChild] public Adw.Bin search_frame; + [GtkChild] public unowned ConversationView conversation_view; + [GtkChild] public unowned ConversationSelector conversation_selector; + [GtkChild] public unowned Adw.Flap search_flap; + [GtkChild] private unowned Stack left_stack; + [GtkChild] private unowned Stack right_stack; + [GtkChild] public unowned Adw.Bin search_frame; public GlobalSearch global_search; diff --git a/main/src/ui/util/data_forms.vala b/main/src/ui/util/data_forms.vala index 7fb9b87d..0b91da15 100644 --- a/main/src/ui/util/data_forms.vala +++ b/main/src/ui/util/data_forms.vala @@ -18,7 +18,7 @@ namespace Dino.Ui.Util { } public static ViewModel.PreferencesRow.Any? get_data_form_field_view_model(DataForms.DataForm.Field field) { - if (field.type_ == null) return null; + if (field.type_ == DataForms.DataForm.Type.UNKNOWN) return null; ViewModel.PreferencesRow.Any? view_model = null; diff --git a/xmpp-vala/src/core/stanza_attribute.vala b/xmpp-vala/src/core/stanza_attribute.vala index 6c6ac579..ba1616a5 100644 --- a/xmpp-vala/src/core/stanza_attribute.vala +++ b/xmpp-vala/src/core/stanza_attribute.vala @@ -56,7 +56,13 @@ public class StanzaAttribute : StanzaEntry { if (ns_uri == state.current_ns_uri || (ns_uri == XMLNS_URI && name == "xmlns")) { return printf(ATTRIBUTE_XML_NO_NS_FORMAT, true); } else { - return printf(ATTRIBUTE_XML_FORMAT, false, state.find_name((!)ns_uri)); + string ns_name = "_"; + try { + ns_name = state.find_name((!)ns_uri); + } catch (IOError e) { + warning("Error finding name: %s", e.message); + } + return printf(ATTRIBUTE_XML_FORMAT, false, ns_name); } } @@ -65,7 +71,13 @@ public class StanzaAttribute : StanzaEntry { if (ns_uri == state.current_ns_uri || (ns_uri == XMLNS_URI && name == "xmlns")) { return printf(ATTRIBUTE_XML_ANSI_NO_NS_FORMAT, true); } else { - return printf(ATTRIBUTE_XML_ANSI_FORMAT, false, state.find_name((!)ns_uri)); + string ns_name = "_"; + try { + ns_name = state.find_name((!)ns_uri); + } catch (IOError e) { + warning("Error finding name: %s", e.message); + } + return printf(ATTRIBUTE_XML_ANSI_FORMAT, false, ns_name); } } } diff --git a/xmpp-vala/src/core/stanza_node.vala b/xmpp-vala/src/core/stanza_node.vala index f44657f1..7a68da62 100644 --- a/xmpp-vala/src/core/stanza_node.vala +++ b/xmpp-vala/src/core/stanza_node.vala @@ -18,54 +18,62 @@ public abstract class StanzaEntry { public string? encoded_val { owned get { if (val == null) return null; - return ENCODABLE_VALUE_CHARS.replace_eval(val, -1, 0, 0, (match_info, result_builder) => { - int start; - match_info.fetch_pos(0, out start, null); - unowned string src = match_info.get_string(); - switch (src[start]) { - case '&': result_builder.append("&"); break; - case '"': result_builder.append("""); break; - case '\'': result_builder.append("'"); break; - case '<': result_builder.append("<"); break; - case '>': result_builder.append(">"); break; - default: error("Unreachable"); break; - } - return false; - }); + try { + return ENCODABLE_VALUE_CHARS.replace_eval(val, -1, 0, 0, (match_info, result_builder) => { + int start; + match_info.fetch_pos(0, out start, null); + unowned string src = match_info.get_string(); + switch (src[start]) { + case '&': result_builder.append("&"); break; + case '"': result_builder.append("""); break; + case '\'': result_builder.append("'"); break; + case '<': result_builder.append("<"); break; + case '>': result_builder.append(">"); break; + default: error("Unreachable"); break; + } + return false; + }); + } catch (RegexError e) { + error("Error encoding entities in string \"%s\": %s", val, e.message); + } } set { if (value == null) { val = null; return; } - val = DECODABLE_VALUE_SEQUENCES.replace_eval(value, -1, 0, 0, (match_info, result_builder) => { - int start, end; - match_info.fetch_pos(0, out start, out end); - unowned string src = match_info.get_string(); - switch (src[start+1]) { - case 'g': result_builder.append_c('>'); break; - case 'l': result_builder.append_c('<'); break; - case 'q': result_builder.append_c('"'); break; - case 'a': - switch (src[start+2]) { - case 'p': result_builder.append_c('\''); break; - case 'm': result_builder.append_c('&'); break; - default: critical("Invalid encoding: %s in %s", match_info.fetch(0), src); break; - } - break; - case '#': - unichar num = -1; - if (src[start+2] == 'x') { - src.substring(start+3, start-end-3).scanf("%x", &num); - } else { - num = int.parse(src.substring(start+2, start-end-2)); - } - result_builder.append_unichar(num); - break; - default: critical("Invalid encoding: %s in %s", match_info.fetch(0), src); break; - } - return false; - }); + try { + val = DECODABLE_VALUE_SEQUENCES.replace_eval(value, -1, 0, 0, (match_info, result_builder) => { + int start, end; + match_info.fetch_pos(0, out start, out end); + unowned string src = match_info.get_string(); + switch (src[start + 1]) { + case 'g': result_builder.append_c('>'); break; + case 'l': result_builder.append_c('<'); break; + case 'q': result_builder.append_c('"'); break; + case 'a': + switch (src[start + 2]) { + case 'p': result_builder.append_c('\''); break; + case 'm': result_builder.append_c('&'); break; + default: critical("Invalid encoding: %s in %s", match_info.fetch(0), src); break; + } + break; + case '#': + unichar num = -1; + if (src[start + 2] == 'x') { + src.substring(start + 3, start - end - 3).scanf("%x", &num); + } else { + num = int.parse(src.substring(start + 2, start - end - 2)); + } + result_builder.append_unichar(num); + break; + default: critical("Invalid encoding: %s in %s", match_info.fetch(0), src); break; + } + return false; + }); + } catch (RegexError e) { + error("Error decoding entities in string \"%s\": %s", value, e.message); + } } } diff --git a/xmpp-vala/src/core/stream_connect.vala b/xmpp-vala/src/core/stream_connect.vala index 7e3843fa..a496fc3c 100644 --- a/xmpp-vala/src/core/stream_connect.vala +++ b/xmpp-vala/src/core/stream_connect.vala @@ -15,7 +15,7 @@ namespace Xmpp { public async XmppStreamResult establish_stream(Jid bare_jid, Gee.List modules, string? log_options, owned TlsXmppStream.OnInvalidCert on_invalid_cert) { Jid remote = bare_jid.domain_jid; - TlsXmppStream.OnInvalidCertWrapper on_invalid_cert_wrapper = new TlsXmppStream.OnInvalidCertWrapper(on_invalid_cert); + TlsXmppStream.OnInvalidCertWrapper on_invalid_cert_wrapper = new TlsXmppStream.OnInvalidCertWrapper((owned) on_invalid_cert); //Lookup xmpp-client and xmpps-client SRV records GLib.List? targets = new GLib.List(); @@ -72,7 +72,13 @@ namespace Xmpp { connection_timeout_id = Timeout.add_seconds(30, () => { warning("Connection attempt timed out"); - stream.disconnect(); + stream.disconnect.begin((_, res) => { + try { + stream.disconnect.end(res); + } catch (IOError e) { + debug("Error while disconnecting: %s", e.message); + } + }); connection_timeout_id = 0; return Source.REMOVE; }); diff --git a/xmpp-vala/src/module/bookmarks_provider.vala b/xmpp-vala/src/module/bookmarks_provider.vala index 6ddcc5af..458ff183 100644 --- a/xmpp-vala/src/module/bookmarks_provider.vala +++ b/xmpp-vala/src/module/bookmarks_provider.vala @@ -8,10 +8,10 @@ public interface BookmarksProvider : Object { public signal void conference_changed(XmppStream stream, Conference conferences); public signal void received_conferences(XmppStream stream, Set conferences); - public async abstract async Set? get_conferences(XmppStream stream); - public async abstract void add_conference(XmppStream stream, Conference conference); - public async abstract void remove_conference(XmppStream stream, Conference conference); - public async abstract void replace_conference(XmppStream stream, Jid muc_jid, Conference modified_conference); + public async abstract async Set? get_conferences(XmppStream stream) throws IOError; + public async abstract void add_conference(XmppStream stream, Conference conference) throws IOError; + public async abstract void remove_conference(XmppStream stream, Conference conference) throws IOError; + public async abstract void replace_conference(XmppStream stream, Jid muc_jid, Conference modified_conference) throws IOError; } } diff --git a/xmpp-vala/src/module/iq/module.vala b/xmpp-vala/src/module/iq/module.vala index bb9260c9..917f6660 100644 --- a/xmpp-vala/src/module/iq/module.vala +++ b/xmpp-vala/src/module/iq/module.vala @@ -23,7 +23,7 @@ namespace Xmpp.Iq { Idle.add(send_iq_async.callback); } }); - stream.write_async(iq.stanza, io_priority, cancellable); + yield stream.write_async(iq.stanza, io_priority, cancellable); ulong cancelled_handler_id = 0; if (cancellable != null) { cancelled_handler_id = cancellable.cancelled.connect(() => Idle.add(send_iq_async.callback)); diff --git a/xmpp-vala/src/module/sasl.vala b/xmpp-vala/src/module/sasl.vala index 035cc723..f0c2d6ed 100644 --- a/xmpp-vala/src/module/sasl.vala +++ b/xmpp-vala/src/module/sasl.vala @@ -73,10 +73,14 @@ namespace Xmpp.Sasl { } else if (node.name == "challenge" && stream.has_flag(Flag.IDENTITY)) { Flag flag = stream.get_flag(Flag.IDENTITY); if (flag.mechanism == Mechanism.SCRAM_SHA_1) { - var challenge_response = compute_challenge_response(node.get_string_content(), flag.password, flag.client_nonce, flag.name); - flag.server_signature = challenge_response.expected_server_signature; - stream.write(new StanzaNode.build("response", NS_URI).add_self_xmlns() - .put_node(new StanzaNode.text(Base64.encode((uchar[]) (challenge_response.response).to_utf8())))); + try { + var challenge_response = compute_challenge_response(node.get_string_content(), flag.password, flag.client_nonce, flag.name); + flag.server_signature = challenge_response.expected_server_signature; + stream.write(new StanzaNode.build("response", NS_URI).add_self_xmlns() + .put_node(new StanzaNode.text(Base64.encode((uchar[]) (challenge_response.response).to_utf8())))); + } catch (Error e) { + warning("Failed processing challenge: %s", e.message); + } } } } @@ -165,7 +169,7 @@ namespace Xmpp.Sasl { public string response { get; set; } } - public static ChallengeResponse compute_challenge_response(string challenge, string password, string client_nonce, string name) { + public static ChallengeResponse compute_challenge_response(string challenge, string password, string client_nonce, string name) throws Error { string challenge_base64 = (string) Base64.decode(challenge); string? server_nonce = null; uint8[] salt = null; diff --git a/xmpp-vala/src/module/session.vala b/xmpp-vala/src/module/session.vala index b1436d1e..fa947624 100644 --- a/xmpp-vala/src/module/session.vala +++ b/xmpp-vala/src/module/session.vala @@ -28,9 +28,13 @@ public class Module : XmppStreamNegotiationModule { stream.add_flag(new Flag()); Iq.Stanza iq = new Iq.Stanza.set(new StanzaNode.build("session", NS_URI).add_self_xmlns()) { to=stream.remote_name }; - Iq.Stanza result_iq = yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq); - if (!result_iq.is_error()) { - stream.get_flag(Flag.IDENTITY).finished = true; + try { + Iq.Stanza result_iq = yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq); + if (!result_iq.is_error()) { + stream.get_flag(Flag.IDENTITY).finished = true; + } + } catch (IOError e) { + warning("Error establishing legacy session: %s", e.message); } } } diff --git a/xmpp-vala/src/module/xep/0004_data_forms.vala b/xmpp-vala/src/module/xep/0004_data_forms.vala index 6b5624da..f481e174 100644 --- a/xmpp-vala/src/module/xep/0004_data_forms.vala +++ b/xmpp-vala/src/module/xep/0004_data_forms.vala @@ -18,6 +18,7 @@ public class DataForm { } public enum Type { + UNKNOWN, BOOLEAN, FIXED, HIDDEN, @@ -44,7 +45,7 @@ public class DataForm { get { return node.get_attribute("label", NS_URI); } set { node.set_attribute("label", value); } } - public virtual Type? type_ { get; internal set; default=null; } + public virtual Type type_ { get; internal set; default=Type.UNKNOWN; } public string? var { get { return node.get_attribute("var", NS_URI); } set { node.set_attribute("var", value); } diff --git a/xmpp-vala/src/module/xep/0030_service_discovery/module.vala b/xmpp-vala/src/module/xep/0030_service_discovery/module.vala index 537e460b..1ba8ac3a 100644 --- a/xmpp-vala/src/module/xep/0030_service_discovery/module.vala +++ b/xmpp-vala/src/module/xep/0030_service_discovery/module.vala @@ -45,7 +45,7 @@ public class Module : XmppStreamModule, Iq.Handler { return yield this.cache.get_entity_identities(jid); } - public async InfoResult? request_info(XmppStream stream, Jid jid) { + public async InfoResult? request_info(XmppStream stream, Jid jid) throws IOError { var future = active_info_requests[jid]; if (future == null) { var promise = new Promise(); @@ -69,7 +69,7 @@ public class Module : XmppStreamModule, Iq.Handler { } } - public async ItemsResult? request_items(XmppStream stream, Jid jid) { + public async ItemsResult? request_items(XmppStream stream, Jid jid) throws IOError { StanzaNode query_node = new StanzaNode.build("query", NS_URI_ITEMS).add_self_xmlns(); Iq.Stanza iq = new Iq.Stanza.get(query_node) { to=jid }; diff --git a/xmpp-vala/src/module/xep/0045_muc/module.vala b/xmpp-vala/src/module/xep/0045_muc/module.vala index 76045172..e4c066f0 100644 --- a/xmpp-vala/src/module/xep/0045_muc/module.vala +++ b/xmpp-vala/src/module/xep/0045_muc/module.vala @@ -215,7 +215,7 @@ public class Module : XmppStreamModule { stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq); } - public async void change_affiliation(XmppStream stream, Jid muc_jid, Jid? user_jid, string? nick, string new_affiliation) { + public async void change_affiliation(XmppStream stream, Jid muc_jid, Jid? user_jid, string? nick, string new_affiliation) throws IOError { StanzaNode item_node = new StanzaNode.build("item", NS_URI_ADMIN) .put_attribute("affiliation", new_affiliation, NS_URI_ADMIN); if (user_jid != null) { @@ -229,7 +229,7 @@ public class Module : XmppStreamModule { yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq); } - public async DataForms.DataForm? get_config_form(XmppStream stream, Jid jid) { + public async DataForms.DataForm? get_config_form(XmppStream stream, Jid jid) throws IOError { Iq.Stanza get_iq = new Iq.Stanza.get(new StanzaNode.build("query", NS_URI_OWNER).add_self_xmlns()) { to=jid }; Iq.Stanza result_iq = yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, get_iq); @@ -241,7 +241,7 @@ public class Module : XmppStreamModule { return null; } - public async void set_config_form(XmppStream stream, Jid jid, DataForms.DataForm data_form) { + public async void set_config_form(XmppStream stream, Jid jid, DataForms.DataForm data_form) throws IOError { StanzaNode stanza_node = new StanzaNode.build("query", NS_URI_OWNER); stanza_node.add_self_xmlns().put_node(data_form.get_submit_node()); Iq.Stanza set_iq = new Iq.Stanza.set(stanza_node) { to=jid }; @@ -420,7 +420,7 @@ public class Module : XmppStreamModule { yield query_affiliation(stream, muc_jid, "owner"); } - private async Gee.List? query_affiliation(XmppStream stream, Jid jid, string affiliation) { + private async Gee.List? query_affiliation(XmppStream stream, Jid jid, string affiliation) throws IOError { Iq.Stanza iq = new Iq.Stanza.get( new StanzaNode.build("query", NS_URI_ADMIN) .add_self_xmlns() @@ -538,14 +538,18 @@ public class ReceivedPipelineListener : StanzaListener { if (item_nodes.size > 0) { var affiliations = new HashMap(); foreach (StanzaNode item_node in item_nodes) { - string jid_str = item_node.get_attribute("jid", Muc.NS_URI_USER); - Jid real_jid = Jid.from_string(jid_str); - string affiliation_str = item_node.get_attribute("affiliation", Muc.NS_URI_USER); - Muc.Affiliation affiliation = Muc.Module.parse_affiliation(affiliation_str); + try { + string jid_str = item_node.get_attribute("jid", Muc.NS_URI_USER); + Jid real_jid = Jid.from_string(jid_str); + string affiliation_str = item_node.get_attribute("affiliation", Muc.NS_URI_USER); + Muc.Affiliation affiliation = Muc.Module.parse_affiliation(affiliation_str); - affiliations[real_jid] = affiliation; + affiliations[real_jid] = affiliation; - stream.get_flag(Flag.IDENTITY).set_offline_member(message.from, real_jid, affiliation); + stream.get_flag(Flag.IDENTITY).set_offline_member(message.from, real_jid, affiliation); + } catch (InvalidJidError e) { + warning("Received invalid affiliation update: %s", e.message); + } } string? mav_since = MucAffiliationsVersioning.get_mav_since(x_node); diff --git a/xmpp-vala/src/module/xep/0048_bookmarks.vala b/xmpp-vala/src/module/xep/0048_bookmarks.vala index 46814e4a..dc009a1e 100644 --- a/xmpp-vala/src/module/xep/0048_bookmarks.vala +++ b/xmpp-vala/src/module/xep/0048_bookmarks.vala @@ -6,7 +6,7 @@ private const string NS_URI = "storage:bookmarks"; public class Module : BookmarksProvider, XmppStreamModule { public static ModuleIdentity IDENTITY = new ModuleIdentity(NS_URI, "0048_bookmarks_module"); - public async Set? get_conferences(XmppStream stream) { + public async Set? get_conferences(XmppStream stream) throws IOError { StanzaNode get_node = new StanzaNode.build("storage", NS_URI).add_self_xmlns(); StanzaNode? result_node = yield stream.get_module(PrivateXmlStorage.Module.IDENTITY).retrieve(stream, get_node); if (result_node == null) return null; @@ -20,7 +20,7 @@ public class Module : BookmarksProvider, XmppStreamModule { return ret; } - private async void set_conferences(XmppStream stream, Set conferences) { + private async void set_conferences(XmppStream stream, Set conferences) throws IOError { StanzaNode storage_node = (new StanzaNode.build("storage", NS_URI)).add_self_xmlns(); foreach (Conference conference in conferences) { Bookmarks1Conference? bookmarks1conference = conference as Bookmarks1Conference; @@ -45,13 +45,13 @@ public class Module : BookmarksProvider, XmppStreamModule { stream.get_module(Module.IDENTITY).received_conferences(stream, conferences); } - public async void add_conference(XmppStream stream, Conference conference) { + public async void add_conference(XmppStream stream, Conference conference) throws IOError { Set? conferences = yield get_conferences(stream); conferences.add(conference); yield set_conferences(stream, conferences); } - public async void replace_conference(XmppStream stream, Jid muc_jid, Conference modified_conference) { + public async void replace_conference(XmppStream stream, Jid muc_jid, Conference modified_conference) throws IOError { Set? conferences = yield get_conferences(stream); foreach (Conference conference in conferences) { if (conference.jid.equals(muc_jid)) { @@ -64,7 +64,7 @@ public class Module : BookmarksProvider, XmppStreamModule { yield set_conferences(stream, conferences); } - public async void remove_conference(XmppStream stream, Conference conference_remove) { + public async void remove_conference(XmppStream stream, Conference conference_remove) throws IOError { Set? conferences = yield get_conferences(stream); conferences.remove(conference_remove); yield set_conferences(stream, conferences); diff --git a/xmpp-vala/src/module/xep/0049_private_xml_storage.vala b/xmpp-vala/src/module/xep/0049_private_xml_storage.vala index 81ccde9b..a6501505 100644 --- a/xmpp-vala/src/module/xep/0049_private_xml_storage.vala +++ b/xmpp-vala/src/module/xep/0049_private_xml_storage.vala @@ -6,13 +6,13 @@ namespace Xmpp.Xep.PrivateXmlStorage { public class Module : XmppStreamModule { public static ModuleIdentity IDENTITY = new ModuleIdentity(NS_URI, "0049_private_xml_storage"); - public async void store(XmppStream stream, StanzaNode node) { + public async void store(XmppStream stream, StanzaNode node) throws IOError { StanzaNode queryNode = new StanzaNode.build("query", NS_URI).add_self_xmlns().put_node(node); Iq.Stanza iq = new Iq.Stanza.set(queryNode); yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq); } - public async StanzaNode? retrieve(XmppStream stream, StanzaNode node) { + public async StanzaNode? retrieve(XmppStream stream, StanzaNode node) throws IOError { StanzaNode queryNode = new StanzaNode.build("query", NS_URI).add_self_xmlns().put_node(node); Iq.Stanza iq = new Iq.Stanza.get(queryNode); Iq.Stanza iq_result = yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq); diff --git a/xmpp-vala/src/module/xep/0054_vcard/module.vala b/xmpp-vala/src/module/xep/0054_vcard/module.vala index 4df1d9a5..4c02a2d1 100644 --- a/xmpp-vala/src/module/xep/0054_vcard/module.vala +++ b/xmpp-vala/src/module/xep/0054_vcard/module.vala @@ -2,7 +2,7 @@ namespace Xmpp.Xep.VCard { private const string NS_URI = "vcard-temp"; private const string NS_URI_UPDATE = NS_URI + ":x:update"; -public async Bytes? fetch_image(XmppStream stream, Jid jid, string hash) { +public async Bytes? fetch_image(XmppStream stream, Jid jid, string hash) throws IOError { Iq.Stanza iq = new Iq.Stanza.get(new StanzaNode.build("vCard", NS_URI).add_self_xmlns()) { to=jid }; Iq.Stanza iq_res = yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq); diff --git a/xmpp-vala/src/module/xep/0060_pubsub.vala b/xmpp-vala/src/module/xep/0060_pubsub.vala index c9af4263..88b9cd31 100644 --- a/xmpp-vala/src/module/xep/0060_pubsub.vala +++ b/xmpp-vala/src/module/xep/0060_pubsub.vala @@ -41,7 +41,7 @@ namespace Xmpp.Xep.Pubsub { retract_listeners.unset(node); } - public async Gee.List? request_all(XmppStream stream, Jid? jid, string node) { // TODO multiple nodes gehen auch + public async Gee.List? request_all(XmppStream stream, Jid? jid, string node) throws IOError { // TODO multiple nodes gehen auch Iq.Stanza request_iq = new Iq.Stanza.get(new StanzaNode.build("pubsub", NS_URI).add_self_xmlns().put_node(new StanzaNode.build("items", NS_URI).put_attribute("node", node))); if (jid != null) request_iq.to = jid; @@ -72,7 +72,7 @@ namespace Xmpp.Xep.Pubsub { XmppStream stream, Jid? jid, string node_id, string? item_id, StanzaNode content, PublishOptions? publish_options = null, bool try_reconfiguring = true - ) { + ) throws IOError { StanzaNode pubsub_node = new StanzaNode.build("pubsub", NS_URI).add_self_xmlns(); StanzaNode publish_node = new StanzaNode.build("publish", NS_URI).put_attribute("node", node_id); pubsub_node.put_node(publish_node); @@ -142,7 +142,7 @@ namespace Xmpp.Xep.Pubsub { stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, null); } - public async DataForms.DataForm? request_node_config(XmppStream stream, Jid? jid, string node_id) { + public async DataForms.DataForm? request_node_config(XmppStream stream, Jid? jid, string node_id) throws IOError { StanzaNode pubsub_node = new StanzaNode.build("pubsub", NS_URI_OWNER).add_self_xmlns(); StanzaNode publish_node = new StanzaNode.build("configure", NS_URI_OWNER).put_attribute("node", node_id); pubsub_node.put_node(publish_node); @@ -154,7 +154,7 @@ namespace Xmpp.Xep.Pubsub { return DataForms.DataForm.create_from_node(data_form_node); } - public async bool submit_node_config(XmppStream stream, DataForms.DataForm data_form, string node_id) { + public async bool submit_node_config(XmppStream stream, DataForms.DataForm data_form, string node_id) throws IOError { StanzaNode submit_node = data_form.get_submit_node(); StanzaNode pubsub_node = new StanzaNode.build("pubsub", Pubsub.NS_URI_OWNER).add_self_xmlns(); @@ -222,7 +222,7 @@ namespace Xmpp.Xep.Pubsub { } } - private async bool change_node_config(XmppStream stream, Jid jid, string node, PublishOptions publish_options) { + private async bool change_node_config(XmppStream stream, Jid jid, string node, PublishOptions publish_options) throws IOError { DataForms.DataForm? data_form = yield stream.get_module(Pubsub.Module.IDENTITY).request_node_config(stream, jid, node); if (data_form == null) return false; diff --git a/xmpp-vala/src/module/xep/0065_socks5_bytestreams.vala b/xmpp-vala/src/module/xep/0065_socks5_bytestreams.vala index 9cfb4afc..4bb46837 100644 --- a/xmpp-vala/src/module/xep/0065_socks5_bytestreams.vala +++ b/xmpp-vala/src/module/xep/0065_socks5_bytestreams.vala @@ -50,7 +50,7 @@ public class Module : XmppStreamModule, Iq.Handler { return get_local_ip_addresses_impl(); } - private async void query_availability(XmppStream stream) { + private async void query_availability(XmppStream stream) throws IOError { ServiceDiscovery.ItemsResult? items_result = yield stream.get_module(ServiceDiscovery.Module.IDENTITY).request_items(stream, stream.remote_name); if (items_result == null) return; diff --git a/xmpp-vala/src/module/xep/0077_in_band_registration.vala b/xmpp-vala/src/module/xep/0077_in_band_registration.vala index 12ed2f1c..0d2dae40 100644 --- a/xmpp-vala/src/module/xep/0077_in_band_registration.vala +++ b/xmpp-vala/src/module/xep/0077_in_band_registration.vala @@ -7,7 +7,7 @@ public const string NS_URI = "jabber:iq:register"; public class Module : XmppStreamNegotiationModule { public static ModuleIdentity IDENTITY = new ModuleIdentity(NS_URI, "0077_in_band_registration"); - public async Form? get_from_server(XmppStream stream, Jid jid) { + public async Form? get_from_server(XmppStream stream, Jid jid) throws IOError { StanzaNode query_node = new StanzaNode.build("query", NS_URI).add_self_xmlns(); Iq.Stanza request_form_iq = new Iq.Stanza.get(query_node) { to=jid }; request_form_iq.to = jid; @@ -16,7 +16,7 @@ public class Module : XmppStreamNegotiationModule { return new Form.from_node(stream, iq_result); } - public async string? submit_to_server(XmppStream stream, Jid jid, Form form) { + public async string? submit_to_server(XmppStream stream, Jid jid, Form form) throws IOError { StanzaNode query_node = new StanzaNode.build("query", NS_URI).add_self_xmlns(); query_node.put_node(form.get_submit_node()); Iq.Stanza iq = new Iq.Stanza.set(query_node) { to=jid }; @@ -30,7 +30,7 @@ public class Module : XmppStreamNegotiationModule { return null; } - public async ErrorStanza? change_password(XmppStream stream, Jid bare_jid, string new_pw) { + public async ErrorStanza? change_password(XmppStream stream, Jid bare_jid, string new_pw) throws IOError { StanzaNode pw_change_node = new StanzaNode.build("query", NS_URI).add_self_xmlns(); StanzaNode username_node = new StanzaNode.build("username", NS_URI); StanzaNode pw_node = new StanzaNode.build("password", NS_URI); diff --git a/xmpp-vala/src/module/xep/0082_date_time_profiles.vala b/xmpp-vala/src/module/xep/0082_date_time_profiles.vala index 3237208e..8cd3cfb1 100644 --- a/xmpp-vala/src/module/xep/0082_date_time_profiles.vala +++ b/xmpp-vala/src/module/xep/0082_date_time_profiles.vala @@ -15,8 +15,8 @@ public TimeZone? parse_tzd(string tzd) { } else { return null; } - int h_offset = unprefixed.substring(0, 2).to_int(); - int m_offset = unprefixed.substring(3, 2).to_int(); + int h_offset = int.parse(unprefixed.substring(0, 2)); + int m_offset = int.parse(unprefixed.substring(3, 2)); int offset = h_offset * 60 * 60 + m_offset * 60; if (tzd.has_prefix("-")) { offset = -offset; diff --git a/xmpp-vala/src/module/xep/0084_user_avatars.vala b/xmpp-vala/src/module/xep/0084_user_avatars.vala index 680c8e78..76ad824b 100644 --- a/xmpp-vala/src/module/xep/0084_user_avatars.vala +++ b/xmpp-vala/src/module/xep/0084_user_avatars.vala @@ -25,7 +25,7 @@ namespace Xmpp.Xep.UserAvatars { stream.get_module(Pubsub.Module.IDENTITY).delete_node(stream, null, NS_URI_METADATA); } - public async Bytes? fetch_image(XmppStream stream, Jid jid, string hash) { + public async Bytes? fetch_image(XmppStream stream, Jid jid, string hash) throws IOError { Gee.List? items = yield stream.get_module(Pubsub.Module.IDENTITY).request_all(stream, jid, NS_URI_DATA); if (items == null || items.size == 0 || items[0].sub_nodes.size == 0) return null; diff --git a/xmpp-vala/src/module/xep/0166_jingle/component.vala b/xmpp-vala/src/module/xep/0166_jingle/component.vala index e30175d5..f08ffbce 100644 --- a/xmpp-vala/src/module/xep/0166_jingle/component.vala +++ b/xmpp-vala/src/module/xep/0166_jingle/component.vala @@ -41,7 +41,11 @@ namespace Xmpp.Xep.Jingle { assert(!this.stream.ready); promise.set_value(stream); if (terminated != null) { - yield stream.close_async(); + try { + yield stream.close_async(); + } catch (IOError e) { + warning("Failed closing stream provided for terminated connection: %s", e.message); + } } } @@ -53,7 +57,11 @@ namespace Xmpp.Xep.Jingle { if (terminated == null) { terminated = (reason_name ?? "") + " - " + (reason_text ?? "") + @"we terminated? $we_terminated"; if (stream.ready) { - yield stream.value.close_async(); + try { + yield stream.value.close_async(); + } catch (IOError e) { + warning("Failed closing stream when terminating connection: %s", e.message); + } } else { promise.set_exception(new IOError.FAILED("Jingle connection failed")); } diff --git a/xmpp-vala/src/module/xep/0166_jingle/content.vala b/xmpp-vala/src/module/xep/0166_jingle/content.vala index f6af1b17..07cadc36 100644 --- a/xmpp-vala/src/module/xep/0166_jingle/content.vala +++ b/xmpp-vala/src/module/xep/0166_jingle/content.vala @@ -67,7 +67,7 @@ public class Xmpp.Xep.Jingle.Content : Object { ContentType content_type, ContentParameters content_params, Transport transport, TransportParameters? transport_params, SecurityPrecondition? security_precondition, SecurityParameters? security_params, - Jid local_full_jid, Jid peer_full_jid) throws Error { + Jid local_full_jid, Jid peer_full_jid) { this.content_name = content_name; this.senders = senders; this.role = Role.RESPONDER; @@ -142,7 +142,7 @@ public class Xmpp.Xep.Jingle.Content : Object { this.content_params.accept(stream, session, this); } - internal void handle_accept(XmppStream stream, ContentNode content_node) { + internal void handle_accept(XmppStream stream, ContentNode content_node) throws IqError { this.transport_params.handle_transport_accept(content_node.transport); this.transport_params.create_transport_connection(stream, this); this.content_params.handle_accept(stream, this.session, this, content_node.description); @@ -157,7 +157,13 @@ public class Xmpp.Xep.Jingle.Content : Object { return; } tried_transport_methods.add(new_transport.ns_uri); - transport_params = new_transport.create_transport_parameters(stream, transport_params.components, local_full_jid, peer_full_jid); + try { + transport_params = new_transport.create_transport_parameters(stream, transport_params.components, local_full_jid, peer_full_jid); + } catch (Error e) { + session.terminate(ReasonElement.FAILED_TRANSPORT, null, e.message); + // TODO should we only terminate this content or really the whole session? + return; + } set_transport_params(transport_params); session.send_transport_replace(this, transport_params); state = State.REPLACING_TRANSPORT; diff --git a/xmpp-vala/src/module/xep/0166_jingle/jingle_flag.vala b/xmpp-vala/src/module/xep/0166_jingle/jingle_flag.vala index 9f0acd27..f451f4c9 100644 --- a/xmpp-vala/src/module/xep/0166_jingle/jingle_flag.vala +++ b/xmpp-vala/src/module/xep/0166_jingle/jingle_flag.vala @@ -24,7 +24,12 @@ public class Xmpp.Xep.Jingle.Flag : XmppStreamFlag { public async Session? get_session(string sid) { if (promises.has_key(sid)) { - return yield promises[sid].future.wait_async(); + try { + return yield promises[sid].future.wait_async(); + } catch (FutureError e) { + warning("Failed waiting for session: %s", e.message); + return null; + } } return sessions[sid]; } diff --git a/xmpp-vala/src/module/xep/0166_jingle/session.vala b/xmpp-vala/src/module/xep/0166_jingle/session.vala index 22e8e978..aa8d6656 100644 --- a/xmpp-vala/src/module/xep/0166_jingle/session.vala +++ b/xmpp-vala/src/module/xep/0166_jingle/session.vala @@ -222,7 +222,12 @@ public class Xmpp.Xep.Jingle.Session : Object { .put_node(content.transport_params.to_transport_stanza_node("content-add"))); Iq.Stanza iq = new Iq.Stanza.set(content_add_node) { to=peer_full_jid }; - yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq); + try { + yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq); + } catch (IOError e) { + warning("Error adding content: %s", e.message); + // FIXME: Probably need to clean up some state + } } private void handle_content_accept(ContentNode content_node) throws IqError { diff --git a/xmpp-vala/src/module/xep/0176_jingle_ice_udp/transport_parameters.vala b/xmpp-vala/src/module/xep/0176_jingle_ice_udp/transport_parameters.vala index 490cc125..53057d9e 100644 --- a/xmpp-vala/src/module/xep/0176_jingle_ice_udp/transport_parameters.vala +++ b/xmpp-vala/src/module/xep/0176_jingle_ice_udp/transport_parameters.vala @@ -39,7 +39,11 @@ public abstract class Xmpp.Xep.JingleIceUdp.IceUdpTransportParameters : Jingle.T remote_pwd = node.get_attribute("pwd"); remote_ufrag = node.get_attribute("ufrag"); foreach (StanzaNode candidateNode in node.get_subnodes("candidate")) { - remote_candidates.add(Candidate.parse(candidateNode)); + try { + remote_candidates.add(Candidate.parse(candidateNode)); + } catch (Jingle.IqError e) { + warning("Ignoring invalid candidate %s: %s", candidateNode.to_string(), e.message); + } } StanzaNode? fingerprint_node = node.get_subnode("fingerprint", DTLS_NS_URI); diff --git a/xmpp-vala/src/module/xep/0191_blocking_command.vala b/xmpp-vala/src/module/xep/0191_blocking_command.vala index 9e5ede78..c037c480 100644 --- a/xmpp-vala/src/module/xep/0191_blocking_command.vala +++ b/xmpp-vala/src/module/xep/0191_blocking_command.vala @@ -88,11 +88,15 @@ public class Module : XmppStreamModule, Iq.Handler { bool has_feature = yield stream.get_module(ServiceDiscovery.Module.IDENTITY).has_entity_feature(stream, stream.remote_name, NS_URI); if (has_feature) { stream.add_flag(new Flag()); - stream.get_flag(Flag.IDENTITY).blocklist = yield get_blocklist(stream); + try { + stream.get_flag(Flag.IDENTITY).blocklist = yield get_blocklist(stream); + } catch (IOError e) { + warning("Failed to retrieve blocklist: %s", e.message); + } } } - private async Gee.List get_blocklist(XmppStream stream) { + private async Gee.List get_blocklist(XmppStream stream) throws IOError { StanzaNode blocklist_node = new StanzaNode.build("blocklist", NS_URI).add_self_xmlns(); Iq.Stanza iq = new Iq.Stanza.get(blocklist_node); diff --git a/xmpp-vala/src/module/xep/0199_ping.vala b/xmpp-vala/src/module/xep/0199_ping.vala index 18fa538c..7bc234bc 100644 --- a/xmpp-vala/src/module/xep/0199_ping.vala +++ b/xmpp-vala/src/module/xep/0199_ping.vala @@ -6,7 +6,7 @@ namespace Xmpp.Xep.Ping { public class Module : XmppStreamModule, Iq.Handler { public static ModuleIdentity IDENTITY = new ModuleIdentity(NS_URI, "0199_ping"); - public async Iq.Stanza send_ping(XmppStream stream, Jid jid) { + public async Iq.Stanza send_ping(XmppStream stream, Jid jid) throws IOError { StanzaNode ping_node = new StanzaNode.build("ping", NS_URI).add_self_xmlns(); Iq.Stanza iq = new Iq.Stanza.get(ping_node) { to=jid }; return yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq, Priority.HIGH); diff --git a/xmpp-vala/src/module/xep/0215_external_service_discovery.vala b/xmpp-vala/src/module/xep/0215_external_service_discovery.vala index 5bad71cd..67f67c05 100644 --- a/xmpp-vala/src/module/xep/0215_external_service_discovery.vala +++ b/xmpp-vala/src/module/xep/0215_external_service_discovery.vala @@ -4,7 +4,7 @@ namespace Xmpp.Xep.ExternalServiceDiscovery { private const string NS_URI = "urn:xmpp:extdisco:2"; - public static async Gee.List request_services(XmppStream stream) { + public static async Gee.List request_services(XmppStream stream) throws IOError { Iq.Stanza request_iq = new Iq.Stanza.get((new StanzaNode.build("services", NS_URI)).add_self_xmlns()) { to=stream.remote_name }; Iq.Stanza response_iq = yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, request_iq); diff --git a/xmpp-vala/src/module/xep/0234_jingle_file_transfer.vala b/xmpp-vala/src/module/xep/0234_jingle_file_transfer.vala index f85049ac..43edefad 100644 --- a/xmpp-vala/src/module/xep/0234_jingle_file_transfer.vala +++ b/xmpp-vala/src/module/xep/0234_jingle_file_transfer.vala @@ -42,7 +42,7 @@ public class Module : Jingle.ContentType, XmppStreamModule { return yield stream.get_module(Jingle.Module.IDENTITY).is_available(stream, required_transport_type, required_components, full_jid); } - public async void offer_file_stream(XmppStream stream, Jid receiver_full_jid, InputStream input_stream, string basename, int64 size, string? precondition_name = null, Object? precondition_options = null) throws Jingle.Error { + public async void offer_file_stream(XmppStream stream, Jid receiver_full_jid, InputStream input_stream, string basename, int64 size, string? precondition_name = null, Object? precondition_options = null) throws Jingle.Error, Jingle.IqError { StanzaNode file_node; StanzaNode description = new StanzaNode.build("description", NS_URI) .add_self_xmlns() diff --git a/xmpp-vala/src/module/xep/0260_jingle_socks5_bytestreams.vala b/xmpp-vala/src/module/xep/0260_jingle_socks5_bytestreams.vala index 852cc7eb..7f44bda2 100644 --- a/xmpp-vala/src/module/xep/0260_jingle_socks5_bytestreams.vala +++ b/xmpp-vala/src/module/xep/0260_jingle_socks5_bytestreams.vala @@ -328,9 +328,13 @@ class LocalListener { } } catch (Error e) { warning("Jingle SOCKS5 bytestream establish error cid %s: %s", cid, e.message); - // Send a "general SOCKS server failure" (0x01) - yield conn.output_stream.write_all_async({0x05, 0x01}, GLib.Priority.DEFAULT, null, out written); - yield conn.output_stream.close_async(); + try { + // Send a "general SOCKS server failure" (0x01) + yield conn.output_stream.write_all_async({0x05, 0x01}, GLib.Priority.DEFAULT, null, out written); + yield conn.output_stream.close_async(); + } catch (Error sub) { + // Ignoring + } } } diff --git a/xmpp-vala/src/module/xep/0272_muji.vala b/xmpp-vala/src/module/xep/0272_muji.vala index 8226da10..7fd0da19 100644 --- a/xmpp-vala/src/module/xep/0272_muji.vala +++ b/xmpp-vala/src/module/xep/0272_muji.vala @@ -86,7 +86,12 @@ namespace Xmpp.Xep.Muji { GroupCall group_call = stream.get_flag(Flag.IDENTITY).calls[muc_jid]; group_call.waiting_for_finish_prepares[promise] = preparing_peers; - return yield promise.future.wait_async(); + try { + return yield promise.future.wait_async(); + } catch (FutureError e) { + warning("Failed waiting for preparing peers: %s", e.message); + return new ArrayList(); + } } private async void compute_payload_intersection(XmppStream stream, GroupCall group_call, string media) { diff --git a/xmpp-vala/src/module/xep/0280_message_carbons.vala b/xmpp-vala/src/module/xep/0280_message_carbons.vala index b396ee54..f8008bfe 100644 --- a/xmpp-vala/src/module/xep/0280_message_carbons.vala +++ b/xmpp-vala/src/module/xep/0280_message_carbons.vala @@ -10,13 +10,21 @@ public class Module : XmppStreamModule { public async void enable(XmppStream stream) { if (stream.get_flag(Flag.IDENTITY) == null) { Iq.Stanza iq = new Iq.Stanza.set(new StanzaNode.build("enable", NS_URI).add_self_xmlns()); - yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq); + try { + yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq); + } catch (IOError e) { + warning("Failed enabling carbons: %s", e.message); + } } } public async void disable(XmppStream stream) { Iq.Stanza iq = new Iq.Stanza.set(new StanzaNode.build("disable", NS_URI).add_self_xmlns()); - yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq); + try { + yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq); + } catch (IOError e) { + warning("Failed enabling carbons: %s", e.message); + } } public override void attach(XmppStream stream) { diff --git a/xmpp-vala/src/module/xep/0313_2_message_archive_management.vala b/xmpp-vala/src/module/xep/0313_2_message_archive_management.vala index 298a1c61..17b93d55 100644 --- a/xmpp-vala/src/module/xep/0313_2_message_archive_management.vala +++ b/xmpp-vala/src/module/xep/0313_2_message_archive_management.vala @@ -61,7 +61,7 @@ namespace Xmpp.MessageArchiveManagement.V2 { return MessageArchiveManagement.create_base_query(stream, mam_params.query_id, fields); } - public async QueryResult query_archive(XmppStream stream, MamQueryParams mam_params, Cancellable? cancellable = null) { + public async QueryResult query_archive(XmppStream stream, MamQueryParams mam_params, Cancellable? cancellable = null) throws IOError { var query_node = create_base_query(stream, mam_params); if (!mam_params.use_ns2_extended) { query_node.put_node(ResultSetManagement.create_set_rsm_node_before(mam_params.end_id)); @@ -70,7 +70,7 @@ namespace Xmpp.MessageArchiveManagement.V2 { return yield MessageArchiveManagement.query_archive(stream, mam_params.mam_server, query_node, cancellable); } - public async QueryResult page_through_results(XmppStream stream, MamQueryParams mam_params, QueryResult prev_result, Cancellable? cancellable = null) { + public async QueryResult page_through_results(XmppStream stream, MamQueryParams mam_params, QueryResult prev_result, Cancellable? cancellable = null) throws IOError { var query_node = create_base_query(stream, mam_params); query_node.put_node(ResultSetManagement.create_set_rsm_node_before(prev_result.first)); diff --git a/xmpp-vala/src/module/xep/0313_message_archive_management.vala b/xmpp-vala/src/module/xep/0313_message_archive_management.vala index a9149d4e..f054a047 100644 --- a/xmpp-vala/src/module/xep/0313_message_archive_management.vala +++ b/xmpp-vala/src/module/xep/0313_message_archive_management.vala @@ -57,7 +57,7 @@ public class Module : XmppStreamModule { return query_node; } - internal async QueryResult query_archive(XmppStream stream, Jid? mam_server, StanzaNode query_node, Cancellable? cancellable = null) { + internal async QueryResult query_archive(XmppStream stream, Jid? mam_server, StanzaNode query_node, Cancellable? cancellable = null) throws IOError { var res = new QueryResult(); Flag flag = Flag.get_flag(stream); diff --git a/xmpp-vala/src/module/xep/0392_consistent_color/hsluv.vala b/xmpp-vala/src/module/xep/0392_consistent_color/hsluv.vala index b45d84de..10aa5d9f 100644 --- a/xmpp-vala/src/module/xep/0392_consistent_color/hsluv.vala +++ b/xmpp-vala/src/module/xep/0392_consistent_color/hsluv.vala @@ -340,9 +340,9 @@ internal string rgb_to_hex(double[] tuple) { internal double[] hex_to_tgb(string hex) { return new double[] { - hex.substring(1, 2).to_long(null, 16) / 255.0, - hex.substring(3, 2).to_long(null, 16) / 255.0, - hex.substring(5, 2).to_long(null, 16) / 255.0 + long.parse(hex.substring(1, 2), 16) / 255.0, + long.parse(hex.substring(3, 2), 16) / 255.0, + long.parse(hex.substring(5, 2), 16) / 255.0 }; } diff --git a/xmpp-vala/src/module/xep/0402_bookmarks2.vala b/xmpp-vala/src/module/xep/0402_bookmarks2.vala index 938af0e9..3a7e5211 100644 --- a/xmpp-vala/src/module/xep/0402_bookmarks2.vala +++ b/xmpp-vala/src/module/xep/0402_bookmarks2.vala @@ -8,7 +8,7 @@ public const string NS_URI_COMPAT = NS_URI + "#compat"; public class Module : BookmarksProvider, XmppStreamModule { public static ModuleIdentity IDENTITY = new ModuleIdentity(NS_URI, "0402_bookmarks2"); - public async Set? get_conferences(XmppStream stream) { + public async Set? get_conferences(XmppStream stream) throws IOError { HashMap? hm = null; Flag? flag = stream.get_flag(Flag.IDENTITY); @@ -35,7 +35,7 @@ public class Module : BookmarksProvider, XmppStreamModule { return ret; } - public async void add_conference(XmppStream stream, Conference conference) { + public async void add_conference(XmppStream stream, Conference conference) throws IOError { StanzaNode conference_node = new StanzaNode.build("conference", NS_URI).add_self_xmlns() .put_attribute("autojoin", conference.autojoin.to_string()); if (conference.name != null) { @@ -56,7 +56,7 @@ public class Module : BookmarksProvider, XmppStreamModule { yield stream.get_module(Pubsub.Module.IDENTITY).publish(stream, stream.get_flag(Bind.Flag.IDENTITY).my_jid.bare_jid, NS_URI, conference.jid.to_string(), conference_node, publish_options); } - public async void replace_conference(XmppStream stream, Jid muc_jid, Conference modified_conference) { + public async void replace_conference(XmppStream stream, Jid muc_jid, Conference modified_conference) throws IOError { yield add_conference(stream, modified_conference); } diff --git a/xmpp-vala/src/module/xep/0461_replies.vala b/xmpp-vala/src/module/xep/0461_replies.vala index af84aa3d..23849d69 100644 --- a/xmpp-vala/src/module/xep/0461_replies.vala +++ b/xmpp-vala/src/module/xep/0461_replies.vala @@ -36,6 +36,5 @@ namespace Xmpp.Xep.Replies { } catch (InvalidJidError e) { return null; } - return null; } } \ No newline at end of file diff --git a/xmpp-vala/tests/color.vala b/xmpp-vala/tests/color.vala index ded67d53..a00710c5 100644 --- a/xmpp-vala/tests/color.vala +++ b/xmpp-vala/tests/color.vala @@ -39,9 +39,9 @@ class ColorTest : Gee.TestCase { public void test_rgb_to_angle() { string[] colors = {"e57373", "f06292", "ba68c8", "9575cd", "7986cb", "64b5f6", "4fc3f7", "4dd0e1", "4db6ac", "81c784", "aed581", "dce775", "fff176", "ffd54f", "ffb74d", "ff8a65"}; foreach(string hex_color in colors) { - uint8 r = (uint8) ((double) hex_color.substring(0, 2).to_long(null, 16)); - uint8 g = (uint8) ((double) hex_color.substring(2, 2).to_long(null, 16)); - uint8 b = (uint8) ((double) hex_color.substring(4, 2).to_long(null, 16)); + uint8 r = (uint8) ((double) long.parse(hex_color.substring(0, 2), 16)); + uint8 g = (uint8) ((double) long.parse(hex_color.substring(2, 2), 16)); + uint8 b = (uint8) ((double) long.parse(hex_color.substring(4, 2), 16)); //print(@"$hex_color, $r, $g, $b, $(ConsistentColor.rgb_to_angle(r, g, b))\n"); } } diff --git a/xmpp-vala/tests/stanza.vala b/xmpp-vala/tests/stanza.vala index 42e19f9a..b573995f 100644 --- a/xmpp-vala/tests/stanza.vala +++ b/xmpp-vala/tests/stanza.vala @@ -21,11 +21,15 @@ class StanzaTest : Gee.TestCase { .put_node(new StanzaNode.build("testbb", "ns3_uri") .add_self_xmlns()); - var xml1 = node1.to_xml(); - var node2 = yield new StanzaReader.for_string(xml1).read_node(); - fail_if_not(node1.equals(node2)); - fail_if_not_eq_str(node1.to_string(), node2.to_string()); - cb(); + try { + var xml1 = node1.to_xml(); + var node2 = yield new StanzaReader.for_string(xml1).read_node(); + fail_if_not(node1.equals(node2)); + fail_if_not_eq_str(node1.to_string(), node2.to_string()); + cb(); + } catch (GLib.Error e) { + cb(e); + } } private async void test_typical_stream(Gee.TestFinishedCallback cb) { @@ -55,12 +59,16 @@ class StanzaTest : Gee.TestCase { .put_node(new StanzaNode.build("body") .put_node(new StanzaNode.text(" I'll send a friar with speed, to Mantua, with my letters to thy lord."))); - var reader = new StanzaReader.for_string(stream); - fail_if_not_eq_node(root_node_cmp, yield reader.read_root_node()); - fail_if_not_eq_node(node_cmp, yield reader.read_node()); - yield reader.read_node(); - yield fail_if_not_end_of_stream(reader); - cb(); + try { + var reader = new StanzaReader.for_string(stream); + fail_if_not_eq_node(root_node_cmp, yield reader.read_root_node()); + fail_if_not_eq_node(node_cmp, yield reader.read_node()); + yield reader.read_node(); + yield fail_if_not_end_of_stream(reader); + cb(); + } catch (GLib.Error e) { + cb(e); + } } private async void fail_if_not_end_of_stream(StanzaReader reader) { @@ -105,13 +113,17 @@ class StanzaTest : Gee.TestCase { .put_node(new StanzaNode.build("required", "urn:ietf:params:xml:ns:xmpp-bind"))); var node2_cmp = new StanzaNode.build("r", "http://jabber.org/protocol/ack"); - var reader = new StanzaReader.for_string(stream); - fail_if_not_eq_node(root_node_cmp, yield reader.read_root_node()); - fail_if_not_eq_node(node_cmp, yield reader.read_node()); - fail_if_not_eq_node(node2_cmp, yield reader.read_node()); - yield reader.read_node(); - yield fail_if_not_end_of_stream(reader); - cb(); + try { + var reader = new StanzaReader.for_string(stream); + fail_if_not_eq_node(root_node_cmp, yield reader.read_root_node()); + fail_if_not_eq_node(node_cmp, yield reader.read_node()); + fail_if_not_eq_node(node2_cmp, yield reader.read_node()); + yield reader.read_node(); + yield fail_if_not_end_of_stream(reader); + cb(); + } catch (GLib.Error e) { + cb(e); + } } private void test_encoded_val() { diff --git a/xmpp-vala/tests/testcase.vala b/xmpp-vala/tests/testcase.vala index 178b6353..10da78f6 100644 --- a/xmpp-vala/tests/testcase.vala +++ b/xmpp-vala/tests/testcase.vala @@ -62,7 +62,7 @@ public abstract class Gee.TestCase : Object { namespace Gee { public delegate void TestMethod (); - public delegate void TestFinishedCallback (); + public delegate void TestFinishedCallback (GLib.Error? error = null); public delegate void AsyncTestMethod (TestFinishedCallback cb); } @@ -128,8 +128,15 @@ private class Gee.TestAsyncAdaptor : Object, TestAdaptor { main_loop.run (); } - public void finish () { - Idle.add (() => { main_loop.quit (); return false; }); + public void finish (GLib.Error? error = null) { + Idle.add(() => { + main_loop.quit(); + if (error != null) { + Test.fail(); + Test.message("Error: %s", error.message); + } + return false; + }); } public bool finish_timeout () { -- cgit v1.3 From 3e136fc57a2e509e5a4dd265a798b196205b0a80 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Sun, 4 Oct 2026 22:02:19 +0200 Subject: Fix more warnings --- libdino/src/service/avatar_manager.vala | 2 +- main/meson.build | 2 +- plugins/omemo/meson.build | 51 --------------------- xmpp-vala/src/core/stanza_node.vala | 2 +- xmpp-vala/src/core/stanza_reader.vala | 11 ++++- xmpp-vala/src/file_content_type.vala | 8 +++- xmpp-vala/src/module/xep/0004_data_forms.vala | 5 -- .../module/xep/0030_service_discovery/module.vala | 17 +++++-- xmpp-vala/src/module/xep/0084_user_avatars.vala | 9 ++-- .../xep/0261_jingle_in_band_bytestreams.vala | 4 -- xmpp-vala/src/module/xep/0272_muji.vala | 10 ++-- .../src/module/xep/0363_http_file_upload.vala | 36 ++++++++------- .../module/xep/0388_extensible_sasl_profile.vala | 24 ++++++---- .../module/xep/0392_consistent_color/hsluv.vala | 53 ++++++++++------------ xmpp-vala/src/module/xep/0410_muc_self_ping.vala | 18 +++++--- .../src/module/xep/0425_message_moderation.vala | 18 +++++--- .../module/xep/0447_stateless_file_sharing.vala | 2 +- .../0490_message_displayed_synchronization.vala | 37 ++++++++++----- xmpp-vala/tests/color.vala | 20 ++++---- xmpp-vala/tests/common.vala | 12 ++--- xmpp-vala/tests/weak_map.vala | 8 ++-- 21 files changed, 171 insertions(+), 178 deletions(-) delete mode 100644 plugins/omemo/meson.build (limited to 'xmpp-vala/src/core') diff --git a/libdino/src/service/avatar_manager.vala b/libdino/src/service/avatar_manager.vala index ac4971ef..7f69f508 100644 --- a/libdino/src/service/avatar_manager.vala +++ b/libdino/src/service/avatar_manager.vala @@ -142,7 +142,7 @@ public class AvatarManager : StreamInteractionModule, Object { public void unset_avatar(Account account) { XmppStream stream = stream_interactor.get_stream(account); if (stream == null) return; - Xmpp.Xep.UserAvatars.unset_avatar(stream); + Xmpp.Xep.UserAvatars.unset_avatar(stream, get_avatar_hash(account, account.bare_jid)); } private void on_account_added(Account account) { diff --git a/main/meson.build b/main/meson.build index cdefcbf7..d9f56e81 100644 --- a/main/meson.build +++ b/main/meson.build @@ -142,7 +142,7 @@ if get_option('rtp').allowed() and dep_gstreamer.found() and dep_gstreamer_app.f voice_sources = files( 'src/plugins/rtp/voice_processor_native.cpp', ) - voice_c_args = c_args + voice_c_args = ['-DG_LOG_DOMAIN="dino"'] if dep_webrtc_audio_processing.version().version_compare('>=2.0') voice_c_args += ['-DWEBRTC2'] elif dep_webrtc_audio_processing.version().version_compare('>=1.0') diff --git a/plugins/omemo/meson.build b/plugins/omemo/meson.build deleted file mode 100644 index 70279946..00000000 --- a/plugins/omemo/meson.build +++ /dev/null @@ -1,51 +0,0 @@ -subdir('po') -dependencies = [ - dep_libadwaita, - dep_dino, - dep_gee, - dep_glib, - dep_gmodule, - dep_gtk4, - dep_libomemo_c, - dep_m, - dep_xmpp_vala, -] -sources = files( -) -sources += gnome.compile_resources( - 'resources', - 'data/gresource.xml', - source_dir: 'data', -) -c_args = vala_c_args + [ - '-DG_LOG_DOMAIN="OMEMO"', - '-DGETTEXT_PACKAGE="dino-omemo"', - '-DLOCALE_INSTALL_DIR="@0@"'.format(get_option('prefix') / get_option('localedir')), -] -vala_args = [ - '--vapidir', meson.current_source_dir() / 'vapi', - # This is to build internal vapi for tests - '--header', meson.current_build_dir() / 'omemo.h', - '--internal-vapi', meson.current_build_dir() / 'omemo-internal.vapi', - '--internal-header', meson.current_build_dir() / 'omemo-internal.h', -] -lib_omemo = shared_library('omemo', sources, name_prefix: '', c_args: c_args, vala_args: vala_args, include_directories: include_directories('src'), dependencies: dependencies, install: true, install_dir: get_option('libdir') / get_option('plugindir'), install_rpath: default_install_rpath) -dep_omemo = declare_dependency(link_with: lib_omemo, include_directories: include_directories('.')) -# This is to use the internal vapi instead of the regular -vapi_omemo_internal = custom_target('omemo-internal-vapi', command: [find_program('touch'), meson.current_build_dir() / 'omemo-internal.vapi'], output: ['omemo-internal.vapi'], depends: lib_omemo) -dep_omemo_internal = declare_dependency(link_args: [lib_omemo.full_path()], include_directories: include_directories('.', 'src'), sources: [vapi_omemo_internal]) - -test_sources = [ - 'tests/native/common.vala', - 'tests/native/testcase.vala', - - 'tests/native/curve25519.vala', - 'tests/native/hkdf.vala', - 'tests/native/session_builder.vala', -] -test_vala_args = [ - '--vapidir', meson.current_source_dir() / 'vapi', -] - -exe_omemo_test = executable('omemo-test', test_sources, c_args: c_args, vala_args: test_vala_args, dependencies: dependencies + dep_omemo_internal, build_rpath: '$ORIGIN', install: false) -test('Tests for omemo', exe_omemo_test) diff --git a/xmpp-vala/src/core/stanza_node.vala b/xmpp-vala/src/core/stanza_node.vala index 7a68da62..56f857d4 100644 --- a/xmpp-vala/src/core/stanza_node.vala +++ b/xmpp-vala/src/core/stanza_node.vala @@ -29,7 +29,7 @@ public abstract class StanzaEntry { case '\'': result_builder.append("'"); break; case '<': result_builder.append("<"); break; case '>': result_builder.append(">"); break; - default: error("Unreachable"); break; + default: error("Unreachable"); } return false; }); diff --git a/xmpp-vala/src/core/stanza_reader.vala b/xmpp-vala/src/core/stanza_reader.vala index ff512497..4828600d 100644 --- a/xmpp-vala/src/core/stanza_reader.vala +++ b/xmpp-vala/src/core/stanza_reader.vala @@ -38,8 +38,15 @@ public class StanzaReader { if (cancellable != null && cancellable.is_cancelled()) throw new IOError.CANCELLED("Input stream is canceled."); try { buffer_fill = (int) yield ((!)input).read_async(buffer, GLib.Priority.DEFAULT, cancellable); - } catch (TlsError.EOF e) { - throw new IOError.CLOSED("End of TLS stream reached"); + } catch (Error e) { + if (e is IOError) { + throw (IOError) e; + } else if (e is TlsError.EOF) { + // The error can be TlsError.EOF instead of IOError.CLOSED, fixing that + throw new IOError.CLOSED("End of TLS stream reached"); + } else { + throw new IOError.FAILED("Unknown error: %s", e.message); + } } if (buffer_fill == 0) throw new IOError.CLOSED("End of input stream reached."); buffer_pos = 0; diff --git a/xmpp-vala/src/file_content_type.vala b/xmpp-vala/src/file_content_type.vala index 3656435e..bae493f6 100644 --- a/xmpp-vala/src/file_content_type.vala +++ b/xmpp-vala/src/file_content_type.vala @@ -14,8 +14,12 @@ namespace Xmpp { } public FileContentType.from_file(File file) { - FileInfo file_info = file.query_info("*", FileQueryInfoFlags.NONE); - this.from_file_info(file_info); + try { + FileInfo file_info = file.query_info("*", FileQueryInfoFlags.NONE); + this.from_file_info(file_info); + } catch (Error e) { + warning("Failed reading file content type: %s", e.message); + } } public string? get_mime_type() { diff --git a/xmpp-vala/src/module/xep/0004_data_forms.vala b/xmpp-vala/src/module/xep/0004_data_forms.vala index f481e174..6c16a53d 100644 --- a/xmpp-vala/src/module/xep/0004_data_forms.vala +++ b/xmpp-vala/src/module/xep/0004_data_forms.vala @@ -83,11 +83,6 @@ public class DataForm { value_node.put_node(new StanzaNode.text(val)); } - internal void add_value_string(string val) { - StanzaNode node = new StanzaNode.build("value"); - node.put_node(new StanzaNode.text(val)); - } - internal Gee.List