aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/module
diff options
context:
space:
mode:
Diffstat (limited to 'xmpp-vala/src/module')
-rw-r--r--xmpp-vala/src/module/presence/module.vala2
-rw-r--r--xmpp-vala/src/module/xep/0054_vcard/module.vala19
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);
}
}