From e8f11178ecc1a333976ba713f532fcae11931b16 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Sun, 12 Mar 2017 13:19:04 +0100 Subject: Move storage into user directory and fix plugin search path --- xmpp-vala/src/module/presence/module.vala | 2 +- xmpp-vala/src/module/xep/0054_vcard/module.vala | 19 ++++++++----------- 2 files changed, 9 insertions(+), 12 deletions(-) (limited to 'xmpp-vala') diff --git a/xmpp-vala/src/module/presence/module.vala b/xmpp-vala/src/module/presence/module.vala index 63545982..7e5dca17 100644 --- a/xmpp-vala/src/module/presence/module.vala +++ b/xmpp-vala/src/module/presence/module.vala @@ -56,9 +56,9 @@ namespace Xmpp.Presence { } public override void attach(XmppStream stream) { + stream.add_flag(new Flag()); stream.received_presence_stanza.connect(on_received_presence_stanza); stream.stream_negotiated.connect(on_stream_negotiated); - stream.add_flag(new Flag()); } public override void detach(XmppStream stream) { diff --git a/xmpp-vala/src/module/xep/0054_vcard/module.vala b/xmpp-vala/src/module/xep/0054_vcard/module.vala index 622f2657..b4c6910b 100644 --- a/xmpp-vala/src/module/xep/0054_vcard/module.vala +++ b/xmpp-vala/src/module/xep/0054_vcard/module.vala @@ -53,21 +53,18 @@ public class Module : XmppStreamModule { } else { iq.to = get_bare_jid(presence.from); } - stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, on_received_vcard); + stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, on_received_vcard, storage); } } - private static void on_received_vcard(XmppStream stream, Iq.Stanza iq) { + private static void on_received_vcard(XmppStream stream, Iq.Stanza iq, Object? storage_obj) { + PixbufStorage? storage = storage_obj as PixbufStorage; if (iq.is_error()) return; - StanzaNode? vcard_node = iq.stanza.get_subnode("vCard", NS_URI); - if (vcard_node == null) return; - StanzaNode? photo_node = vcard_node.get_subnode("PHOTO", NS_URI); - if (photo_node == null) return; - StanzaNode? binary_node = photo_node.get_subnode("BINVAL", NS_URI); - if (binary_node == null) return; - string? content = binary_node.get_string_content(); - if (content == null) return; - string sha1 = Checksum.compute_for_data(ChecksumType.SHA1, content.data); + string? res = iq.stanza.get_deep_string_content(@"$NS_URI:vCard", "PHOTO", "BINVAL"); + if (res == null) return; + uint8[] content = Base64.decode(res); + string sha1 = Checksum.compute_for_data(ChecksumType.SHA1, content); + storage.store(sha1, content); stream.get_module(IDENTITY).received_avatar(stream, iq.from, sha1); } } -- cgit v1.2.3-54-g00ecf