diff options
Diffstat (limited to 'xmpp-vala/src')
| -rw-r--r-- | xmpp-vala/src/core/stanza_node.vala | 2 | ||||
| -rw-r--r-- | xmpp-vala/src/core/stanza_reader.vala | 11 | ||||
| -rw-r--r-- | xmpp-vala/src/file_content_type.vala | 8 | ||||
| -rw-r--r-- | xmpp-vala/src/module/xep/0004_data_forms.vala | 5 | ||||
| -rw-r--r-- | xmpp-vala/src/module/xep/0030_service_discovery/module.vala | 15 | ||||
| -rw-r--r-- | xmpp-vala/src/module/xep/0084_user_avatars.vala | 9 | ||||
| -rw-r--r-- | xmpp-vala/src/module/xep/0261_jingle_in_band_bytestreams.vala | 4 | ||||
| -rw-r--r-- | xmpp-vala/src/module/xep/0272_muji.vala | 10 | ||||
| -rw-r--r-- | xmpp-vala/src/module/xep/0363_http_file_upload.vala | 30 | ||||
| -rw-r--r-- | xmpp-vala/src/module/xep/0388_extensible_sasl_profile.vala | 24 | ||||
| -rw-r--r-- | xmpp-vala/src/module/xep/0392_consistent_color/hsluv.vala | 53 | ||||
| -rw-r--r-- | xmpp-vala/src/module/xep/0410_muc_self_ping.vala | 18 | ||||
| -rw-r--r-- | xmpp-vala/src/module/xep/0425_message_moderation.vala | 18 | ||||
| -rw-r--r-- | xmpp-vala/src/module/xep/0447_stateless_file_sharing.vala | 2 | ||||
| -rw-r--r-- | xmpp-vala/src/module/xep/0490_message_displayed_synchronization.vala | 37 |
15 files changed, 145 insertions, 101 deletions
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<Option>? get_options() { Gee.List<Option> ret = new ArrayList<Option>(); Gee.List<StanzaNode> option_nodes = node.get_subnodes("option", NS_URI); 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 1ba8ac3a..20666820 100644 --- a/xmpp-vala/src/module/xep/0030_service_discovery/module.vala +++ b/xmpp-vala/src/module/xep/0030_service_discovery/module.vala @@ -53,10 +53,14 @@ public class Module : XmppStreamModule, Iq.Handler { active_info_requests[jid] = future; Iq.Stanza iq = new Iq.Stanza.get(new StanzaNode.build("query", NS_URI_INFO).add_self_xmlns()) { to=jid }; - Iq.Stanza iq_response = yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq); - InfoResult? result = InfoResult.create_from_iq(iq_response); + try { + Iq.Stanza iq_response = yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq); + InfoResult? result = InfoResult.create_from_iq(iq_response); - promise.set_value(result); + promise.set_value(result); + } catch (IOError e) { + promise.set_exception(e); + } active_info_requests.unset(jid); } @@ -64,6 +68,11 @@ public class Module : XmppStreamModule, Iq.Handler { InfoResult? res = yield future.wait_async(); return res; } catch (FutureError error) { + if (error is FutureError.EXCEPTION) { + if (future.exception is IOError) { + throw (IOError) future.exception; + } + } warning("Future error when waiting for info request result: %s", error.message); return null; } diff --git a/xmpp-vala/src/module/xep/0084_user_avatars.vala b/xmpp-vala/src/module/xep/0084_user_avatars.vala index 76ad824b..4e96dd8f 100644 --- a/xmpp-vala/src/module/xep/0084_user_avatars.vala +++ b/xmpp-vala/src/module/xep/0084_user_avatars.vala @@ -20,9 +20,12 @@ namespace Xmpp.Xep.UserAvatars { stream.get_module(Pubsub.Module.IDENTITY).publish.begin(stream, null, NS_URI_METADATA, sha1, metadata_node); } - public void unset_avatar(XmppStream stream) { - StanzaNode metadata_node = new StanzaNode.build("metadata", NS_URI_METADATA).add_self_xmlns(); - stream.get_module(Pubsub.Module.IDENTITY).delete_node(stream, null, NS_URI_METADATA); + public void unset_avatar(XmppStream stream, string? hash = null) { + var pubsub_module = stream.get_module(Pubsub.Module.IDENTITY); + pubsub_module.delete_node(stream, null, NS_URI_METADATA); + if (hash != null) { + pubsub_module.retract_item.begin(stream, null, NS_URI_DATA, hash, (_, res) => pubsub_module.retract_item.end(res)); + } } public async Bytes? fetch_image(XmppStream stream, Jid jid, string hash) throws IOError { diff --git a/xmpp-vala/src/module/xep/0261_jingle_in_band_bytestreams.vala b/xmpp-vala/src/module/xep/0261_jingle_in_band_bytestreams.vala index 09eaf711..09134a61 100644 --- a/xmpp-vala/src/module/xep/0261_jingle_in_band_bytestreams.vala +++ b/xmpp-vala/src/module/xep/0261_jingle_in_band_bytestreams.vala @@ -65,10 +65,6 @@ class Parameters : Jingle.TransportParameters, Object { return new Parameters(Jingle.Role.RESPONDER, peer_full_jid, sid, block_size); } - public string transport_ns_uri() { - return NS_URI; - } - public void set_content(Jingle.Content content) { } diff --git a/xmpp-vala/src/module/xep/0272_muji.vala b/xmpp-vala/src/module/xep/0272_muji.vala index 7fd0da19..b287295c 100644 --- a/xmpp-vala/src/module/xep/0272_muji.vala +++ b/xmpp-vala/src/module/xep/0272_muji.vala @@ -56,9 +56,13 @@ namespace Xmpp.Xep.Muji { muji_node.put_node(content_node); } - Presence.Stanza presence_stanza = new Presence.Stanza() { to=muc_jid.with_resource(group_call.our_nick) }; - presence_stanza.stanza.put_node(muji_node); - stream.get_module(Presence.Module.IDENTITY).send_presence(stream, presence_stanza); + try { + Presence.Stanza presence_stanza = new Presence.Stanza() { to=muc_jid.with_resource(group_call.our_nick) }; + presence_stanza.stanza.put_node(muji_node); + stream.get_module(Presence.Module.IDENTITY).send_presence(stream, presence_stanza); + } catch (InvalidJidError e) { + error("Group call participant jid was invalid: %s", e.message); + } return group_call; } diff --git a/xmpp-vala/src/module/xep/0363_http_file_upload.vala b/xmpp-vala/src/module/xep/0363_http_file_upload.vala index cba422ba..bd82109b 100644 --- a/xmpp-vala/src/module/xep/0363_http_file_upload.vala +++ b/xmpp-vala/src/module/xep/0363_http_file_upload.vala @@ -117,24 +117,28 @@ public class Module : XmppStreamModule { public override string get_id() { return IDENTITY.id; } private async void query_availability(XmppStream stream) { - ServiceDiscovery.InfoResult? info_result = yield stream.get_module(ServiceDiscovery.Module.IDENTITY).request_info(stream, stream.remote_name); - bool available = check_ns_in_info(stream, stream.remote_name, info_result); - if (!available) { - ServiceDiscovery.ItemsResult? items_result = yield stream.get_module(ServiceDiscovery.Module.IDENTITY).request_items(stream, stream.remote_name); - if (items_result == null) return; + try { + ServiceDiscovery.InfoResult? info_result = yield stream.get_module(ServiceDiscovery.Module.IDENTITY).request_info(stream, stream.remote_name); + bool available = check_ns_in_info(stream, stream.remote_name, info_result); + if (!available) { + ServiceDiscovery.ItemsResult? items_result = yield stream.get_module(ServiceDiscovery.Module.IDENTITY).request_items(stream, stream.remote_name); + if (items_result == null) return; - for (int i = 0; i < 2; i++) { - foreach (Xep.ServiceDiscovery.Item item in items_result.items) { + for (int i = 0; i < 2; i++) { + foreach (Xep.ServiceDiscovery.Item item in items_result.items) { - // First try the promising items and only afterwards all the others - bool promising_upload_item = item.jid.to_string().has_prefix("upload"); - if ((i == 0 && !promising_upload_item) || (i == 1) && promising_upload_item) continue; + // First try the promising items and only afterwards all the others + bool promising_upload_item = item.jid.to_string().has_prefix("upload"); + if ((i == 0 && !promising_upload_item) || (i == 1) && promising_upload_item) continue; - ServiceDiscovery.InfoResult? info_result2 = yield stream.get_module(ServiceDiscovery.Module.IDENTITY).request_info(stream, item.jid); - bool available2 = check_ns_in_info(stream, item.jid, info_result2); - if (available2) return; + ServiceDiscovery.InfoResult? info_result2 = yield stream.get_module(ServiceDiscovery.Module.IDENTITY).request_info(stream, item.jid); + bool available2 = check_ns_in_info(stream, item.jid, info_result2); + if (available2) return; + } } } + } catch (IOError e) { + warning("Error querying file upload availability: %s", e.message); } } diff --git a/xmpp-vala/src/module/xep/0388_extensible_sasl_profile.vala b/xmpp-vala/src/module/xep/0388_extensible_sasl_profile.vala index 1c6afb30..54d00482 100644 --- a/xmpp-vala/src/module/xep/0388_extensible_sasl_profile.vala +++ b/xmpp-vala/src/module/xep/0388_extensible_sasl_profile.vala @@ -43,19 +43,27 @@ namespace Xmpp.Xep.ExtensibleSaslProfile { stream.expect_further_negotiation_stanzas = true; var authorisation_identifier = node.get_subnode("authorization-identifier", NS_URI); - string jid_string = authorisation_identifier.get_string_content(); - Jid jid = Jid.from_string(jid_string); + string jid_string = authorisation_identifier != null ? authorisation_identifier.get_string_content() : ""; + try { + Jid jid = Jid.from_string(jid_string); - foreach (var inline_provider in inline_activation_providers.values) { - inline_provider.on_bound(stream, jid, node); + foreach (var inline_provider in inline_activation_providers.values) { + inline_provider.on_bound(stream, jid, node); + } + } catch (InvalidJidError e) { + warning("Server provided invalid authorization-identifier \"%s\": %s", jid_string, e.message); } } 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("Error computing challenge response: %s", e.message); + } } } else if (node.name == "failure") { stream.remove_flag(stream.get_flag(Flag.IDENTITY)); 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 10aa5d9f..9efe0970 100644 --- a/xmpp-vala/src/module/xep/0392_consistent_color/hsluv.vala +++ b/xmpp-vala/src/module/xep/0392_consistent_color/hsluv.vala @@ -1,4 +1,4 @@ -namespace Hsluv { +namespace Xmpp.Xep.ConsistentColor.Hsluv { private const double[] M0 = { 3.240969941904521, -1.537383177570093, -0.498610760293 }; private const double[] M1 = { -0.96924363628087, 1.87596750150772, 0.041555057407175 }; @@ -8,10 +8,6 @@ private const double[] MInv0 = { 0.41239079926595, 0.35758433938387, 0.180480788 private const double[] MInv1 = { 0.21263900587151, 0.71516867876775, 0.072192315360733 }; private const double[] MInv2 = { 0.019330818715591, 0.11919477979462, 0.95053215224966 }; -private double RefX = 0.95045592705167; -private double RefY = 1.0; -private double RefZ = 1.089057750759878; - private double RefU = 0.19783000664283; private double RefV = 0.46831999493879; @@ -129,22 +125,19 @@ private double to_linear(double c) { } private int[] rgb_prepare(double[] tuple) { - for (int i = 0; i < tuple.length; ++i) { - tuple[i] = round(tuple[i], 3); - } - - for (int i = 0; i < tuple.length; ++i) { - double ch = tuple[i]; - - if (ch < -0.0001 || ch > 1.0001) { - return null; //throw new Error("Illegal rgb value: " + ch); - } - } - var results = new int[tuple.length]; for (int i = 0; i < tuple.length; ++i) { - results[i] = (int) Math.round(tuple[i] * 255); + double ch = round(tuple[i], 3); + if (ch < -0.0001) { + warning("RGB value underflow: %f", tuple[i]); + results[i] = 0; + } else if (ch > 1.0001) { + warning("RGB value overflow: %f", tuple[i]); + results[i] = 255; + } else { + results[i] = (int) Math.round(ch * 255); + } } return results; @@ -174,17 +167,17 @@ internal double[] rgb_to_xyz(double[] tuple) { private double y_to_l(double Y) { if (Y <= Epsilon) { - return (Y / RefY) * Kappa; + return Y * Kappa; } else { - return 116 * Math.pow(Y / RefY, 1.0 / 3.0) - 16; + return 116 * Math.pow(Y, 1.0 / 3.0) - 16; } } private double l_to_y(double L) { if (L <= 8) { - return RefY * L / Kappa; + return L / Kappa; } else { - return RefY * Math.pow((L + 16) / 116, 3); + return Math.pow((L + 16) / 116, 3); } } @@ -356,37 +349,37 @@ internal double[] rgb_to_lch(double[] tuple) { // Rgb <--> Hsluv(p) -internal double[] hsluv_to_rgb(double[] tuple) { +public double[] hsluv_to_rgb(double[] tuple) { return lch_to_rgb(hsluv_to_lch(tuple)); } -internal double[] rgb_to_hsluv(double[] tuple) { +public double[] rgb_to_hsluv(double[] tuple) { return lch_to_hsluv(rgb_to_lch(tuple)); } -internal double[] hpluv_to_rgb(double[] tuple) { +public double[] hpluv_to_rgb(double[] tuple) { return lch_to_rgb(hpluv_to_lch(tuple)); } -internal double[] rgb_to_hpluv(double[] tuple) { +public double[] rgb_to_hpluv(double[] tuple) { return lch_to_hpluv(rgb_to_lch(tuple)); } // Hex -internal string hsluv_to_hex(double[] tuple) { +public string hsluv_to_hex(double[] tuple) { return rgb_to_hex(hsluv_to_rgb(tuple)); } -internal string hpluv_to_hex(double[] tuple) { +public string hpluv_to_hex(double[] tuple) { return rgb_to_hex(hpluv_to_rgb(tuple)); } -internal double[] hex_to_hsluv(string s) { +public double[] hex_to_hsluv(string s) { return rgb_to_hsluv(hex_to_tgb(s)); } -internal double[] hex_to_hpluv(string s) { +public double[] hex_to_hpluv(string s) { return rgb_to_hpluv(hex_to_tgb(s)); } diff --git a/xmpp-vala/src/module/xep/0410_muc_self_ping.vala b/xmpp-vala/src/module/xep/0410_muc_self_ping.vala index 84772333..6511789e 100644 --- a/xmpp-vala/src/module/xep/0410_muc_self_ping.vala +++ b/xmpp-vala/src/module/xep/0410_muc_self_ping.vala @@ -1,16 +1,20 @@ namespace Xmpp.Xep.MucSelfPing { public static async bool is_joined(XmppStream stream, Jid jid) { - Iq.Stanza iq_result = yield stream.get_module(Xmpp.Xep.Ping.Module.IDENTITY).send_ping(stream, jid); + try { + Iq.Stanza iq_result = yield stream.get_module(Xmpp.Xep.Ping.Module.IDENTITY).send_ping(stream, jid); - if (!iq_result.is_error()) { - return true; - } else { - var error_stanza = iq_result.get_error(); - if (error_stanza.condition in new string[] {ErrorStanza.CONDITION_SERVICE_UNAVAILABLE, ErrorStanza.CONDITION_FEATURE_NOT_IMPLEMENTED}) { - // the client is joined, but the pinged client does not implement XMPP Ping + if (!iq_result.is_error()) { return true; + } else { + var error_stanza = iq_result.get_error(); + if (error_stanza.condition in new string[] {ErrorStanza.CONDITION_SERVICE_UNAVAILABLE, ErrorStanza.CONDITION_FEATURE_NOT_IMPLEMENTED}) { + // the client is joined, but the pinged client does not implement XMPP Ping + return true; + } } + } catch (IOError e) { + // Ignoring, same as if ping failed } return false; } diff --git a/xmpp-vala/src/module/xep/0425_message_moderation.vala b/xmpp-vala/src/module/xep/0425_message_moderation.vala index 80fab905..934e5ff3 100644 --- a/xmpp-vala/src/module/xep/0425_message_moderation.vala +++ b/xmpp-vala/src/module/xep/0425_message_moderation.vala @@ -7,13 +7,17 @@ namespace Xmpp.Xep.MessageModeration { * @return whether the moderation was successful */ public static async bool moderate(XmppStream stream, Jid muc_jid, string message_id) { - StanzaNode moderate_node = new StanzaNode.build("moderate", NS_URI) - .add_self_xmlns() - .put_attribute("id", message_id) - .put_node(new StanzaNode.build("retract", Xep.MessageRetraction.NS_URI).add_self_xmlns()); - Iq.Stanza iq = new Iq.Stanza.set(moderate_node) { to = muc_jid }; + try { + StanzaNode moderate_node = new StanzaNode.build("moderate", NS_URI) + .add_self_xmlns() + .put_attribute("id", message_id) + .put_node(new StanzaNode.build("retract", Xep.MessageRetraction.NS_URI).add_self_xmlns()); + Iq.Stanza iq = new Iq.Stanza.set(moderate_node) { to = muc_jid }; - Iq.Stanza result_stanza = yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq); - return !result_stanza.is_error(); + Iq.Stanza result_stanza = yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq); + return !result_stanza.is_error(); + } catch (IOError e) { + return false; + } } }
\ No newline at end of file diff --git a/xmpp-vala/src/module/xep/0447_stateless_file_sharing.vala b/xmpp-vala/src/module/xep/0447_stateless_file_sharing.vala index 86da6a3a..7e9b12ba 100644 --- a/xmpp-vala/src/module/xep/0447_stateless_file_sharing.vala +++ b/xmpp-vala/src/module/xep/0447_stateless_file_sharing.vala @@ -5,7 +5,7 @@ namespace Xmpp.Xep.StatelessFileSharing { public const string NS_URI = "urn:xmpp:sfs:0"; - public static Gee.List<FileShare> get_file_shares(MessageStanza message) { + public static Gee.List<FileShare>? get_file_shares(MessageStanza message) { var ret = new ArrayList<FileShare>(); foreach (StanzaNode file_sharing_node in message.stanza.get_subnodes("file-sharing", NS_URI)) { var metadata = Xep.FileMetadataElement.get_file_metadata(file_sharing_node); diff --git a/xmpp-vala/src/module/xep/0490_message_displayed_synchronization.vala b/xmpp-vala/src/module/xep/0490_message_displayed_synchronization.vala index 38437735..b129c571 100644 --- a/xmpp-vala/src/module/xep/0490_message_displayed_synchronization.vala +++ b/xmpp-vala/src/module/xep/0490_message_displayed_synchronization.vala @@ -10,15 +10,19 @@ namespace Xmpp.Xep.MessageDisplayedSynchronization { private void handle_displayed_node_item(XmppStream stream, string? id, StanzaNode? item) { if (id == null || item == null) return; - Jid conversation_jid = Jid.from_string(id); - StanzaNode? stanza_id_node = item.get_subnode("stanza-id", UniqueStableStanzaIDs.NS_URI); - if (stanza_id_node == null || stanza_id_node.get_attribute("by") == null || stanza_id_node.get_attribute("id") == null) return; - Jid stanza_id_by_jid = Jid.from_string(stanza_id_node.get_attribute("by")); - string stanza_id = stanza_id_node.get_attribute("id"); - if (stream.has_flag(Flag.IDENTITY)) { - stream.get_flag(Flag.IDENTITY).learn_mds(conversation_jid, stanza_id_by_jid, stanza_id); + try { + Jid conversation_jid = Jid.from_string(id); + StanzaNode? stanza_id_node = item.get_subnode("stanza-id", UniqueStableStanzaIDs.NS_URI); + if (stanza_id_node == null || stanza_id_node.get_attribute("by") == null || stanza_id_node.get_attribute("id") == null) return; + Jid stanza_id_by_jid = Jid.from_string(stanza_id_node.get_attribute("by")); + string stanza_id = stanza_id_node.get_attribute("id"); + if (stream.has_flag(Flag.IDENTITY)) { + stream.get_flag(Flag.IDENTITY).learn_mds(conversation_jid, stanza_id_by_jid, stanza_id); + } + on_message_displayed(conversation_jid, stanza_id_by_jid, stanza_id); + } catch (InvalidJidError e) { + warning("Received mds item with invalid jid, ignoring: %s", e.message); } - on_message_displayed(conversation_jid, stanza_id_by_jid, stanza_id); } private void on_pubsub_item(XmppStream stream, Jid jid, string id, StanzaNode? item) { @@ -32,9 +36,13 @@ namespace Xmpp.Xep.MessageDisplayedSynchronization { private void on_initial_presence_sent(XmppStream stream) { var pubsub = stream.get_module(Pubsub.Module.IDENTITY); pubsub.request_all.begin(stream, null, NS_URI, (_, res) => { - Gee.List<StanzaNode>? items = pubsub.request_all.end(res); - foreach (StanzaNode node_item in items) { - handle_displayed_node_item(stream, node_item.get_attribute("id"), node_item.get_subnode("displayed", NS_URI)); + try { + Gee.List<StanzaNode>? items = pubsub.request_all.end(res); + foreach (StanzaNode node_item in items) { + handle_displayed_node_item(stream, node_item.get_attribute("id"), node_item.get_subnode("displayed", NS_URI)); + } + } catch (IOError e) { + warning("Failed requesting initial mds set: %s", e.message); } }); } @@ -50,7 +58,12 @@ namespace Xmpp.Xep.MessageDisplayedSynchronization { .set_max_items("max") .set_send_last_published_item("never") .set_access_model("whitelist"); - return yield pubsub.publish(stream, stream.get_flag(Bind.Flag.IDENTITY).my_jid.bare_jid, NS_URI, conversation_jid.to_string(), node, options); + try { + return yield pubsub.publish(stream, stream.get_flag(Bind.Flag.IDENTITY).my_jid.bare_jid, NS_URI, conversation_jid.to_string(), node, options); + } catch (IOError e) { + warning("Failed publishing mds item: %s", e.message); + return false; + } } public override void attach(XmppStream stream) { |
