diff options
author | Marvin W <git@larma.de> | 2017-03-12 13:19:04 +0100 |
---|---|---|
committer | Marvin W <git@larma.de> | 2017-03-12 14:09:32 +0100 |
commit | e8f11178ecc1a333976ba713f532fcae11931b16 (patch) | |
tree | 71ef4de63e27203780f3d5bfaa1662d97faaca16 /xmpp-vala/src/module/xep/0054_vcard | |
parent | a9ea0e9f87e71c60bc570066525d3e3634fbdcc0 (diff) | |
download | dino-e8f11178ecc1a333976ba713f532fcae11931b16.tar.gz dino-e8f11178ecc1a333976ba713f532fcae11931b16.zip |
Move storage into user directory and fix plugin search path
Diffstat (limited to 'xmpp-vala/src/module/xep/0054_vcard')
-rw-r--r-- | xmpp-vala/src/module/xep/0054_vcard/module.vala | 19 |
1 files changed, 8 insertions, 11 deletions
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); } } |