1 local verse = require "verse"; |
1 local verse = require "verse"; |
2 |
2 |
3 local xmlns_vcard, xmlns_vcard_update = "vcard-temp", "vcard-temp:x:update"; |
3 -- local xmlns_vcard = "vcard-temp"; |
|
4 local xmlns_vcard_update = "vcard-temp:x:update"; |
4 |
5 |
5 local sha1 = require("util.hashes").sha1; |
6 local sha1 = require("util.hashes").sha1; |
6 |
7 |
7 local ok, fun = pcall(function() |
8 local ok, fun = pcall(function() |
8 local unb64 = require("util.encodings").base64.decode; |
9 local unb64 = require("util.encodings").base64.decode; |
41 else |
42 else |
42 x_vcard_update = nil; |
43 x_vcard_update = nil; |
43 end |
44 end |
44 end |
45 end |
45 |
46 |
46 local _set_vcard = stream.set_vcard; |
|
47 |
47 |
48 --[[ TODO Complete this, it's probably broken. |
48 --[[ TODO Complete this, it's probably broken. |
49 -- Maybe better to hook outgoing stanza? |
49 -- Maybe better to hook outgoing stanza? |
|
50 local _set_vcard = stream.set_vcard; |
50 function stream:set_vcard(vCard, callback) |
51 function stream:set_vcard(vCard, callback) |
51 _set_vcard(vCard, function(event, ...) |
52 _set_vcard(vCard, function(event, ...) |
52 if event.attr.type == "result" then |
53 if event.attr.type == "result" then |
53 local vCard_ = response:get_child("vCard", xmlns_vcard); |
54 local vCard_ = response:get_child("vCard", xmlns_vcard); |
54 if vCard_ then |
55 if vCard_ then |
61 end); |
62 end); |
62 end |
63 end |
63 --]] |
64 --]] |
64 |
65 |
65 local initial_vcard_fetch_started; |
66 local initial_vcard_fetch_started; |
66 stream:hook("ready", function(event) |
67 stream:hook("ready", function() |
67 if initial_vcard_fetch_started then return; end |
68 if initial_vcard_fetch_started then return; end |
68 initial_vcard_fetch_started = true; |
69 initial_vcard_fetch_started = true; |
69 -- if stream:jid_supports(nil, xmlns_vcard) then TODO this, correctly |
70 -- if stream:jid_supports(nil, xmlns_vcard) then TODO this, correctly |
70 stream:get_vcard(nil, function(response) |
71 stream:get_vcard(nil, function(response) |
71 if response then |
72 if response then |