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 | |
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')
-rw-r--r-- | xmpp-vala/src/module/presence/module.vala | 2 | ||||
-rw-r--r-- | xmpp-vala/src/module/xep/0054_vcard/module.vala | 19 |
2 files changed, 9 insertions, 12 deletions
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); } } |