# HG changeset patch # User Emmanuel Gil Peyrot # Date 1590263957 -7200 # Node ID 6a7a99f5a0ca8c8e7dc5446ca0b98f0e7270fea2 # Parent 9ada1963558c3a0884ed0a05d30e59028bed4361 Add pubsub#access_model retrieval for the vCard4 node. diff --git a/index.xhtml b/index.xhtml --- a/index.xhtml +++ b/index.xhtml @@ -104,7 +104,7 @@

diff --git a/vcard.js b/vcard.js --- a/vcard.js +++ b/vcard.js @@ -16,6 +16,28 @@ function initVCard(connection) { .c('item', {id: 'current'}); connection.sendIQ(iq, onVCard4, onVCard4RetrievalError); displaySpinner(spinner_img); + getAccessModel(); + + function getAccessModel() + { + vcard_access.disabled = true; + displaySpinner(access_spinner_img); + retrieveConfiguration(connection, 'urn:xmpp:vcard4').then((access_model) => { + if (access_model !== null) { + if (access_model === 'open') + vcard_access.value = 'open'; + else if (access_model === 'presence') + vcard_access.value = 'presence'; + else + console.log('Unsupported vCard4 access model: ' + access_model); + vcard_access.disabled = false; + } + hideSpinner(access_spinner_img); + }, (reason) => { + console.log('Failed to retrieve vCard4 configuration:', reason); + hideSpinner(access_spinner_img); + }); + } function onVCard4(result_iq) { @@ -37,6 +59,7 @@ function initVCard(connection) { vcard_bday.value = vcard_data.bday; vcard_bday.disabled = false; hideSpinner(spinner_img); + getAccessModel(); } function onVCard4RetrievalError(iq, string) @@ -50,6 +73,7 @@ function initVCard(connection) { vcard_email.disabled = false; vcard_bday.disabled = false; hideSpinner(spinner_img); + vcard_access.disabled = true; } function setVCard4() { @@ -67,6 +91,7 @@ function initVCard(connection) { .c('date').t(vcard_bday.value).up().up(); connection.sendIQ(iq, onVCard4Changed, onVCard4ChangeError); displaySpinner(spinner_img); + vcard_access.disabled = true; } vcard_fn.addEventListener('change', setVCard4); @@ -77,14 +102,15 @@ function initVCard(connection) { { console.log('Successfully set vCard4.') spinnerOk(spinner_img); + getAccessModel(); } function onVCard4ChangeError(iq) { - const string = parseErrorIq(iq); - string = 'Failed to set vCard4: ' + string; + const string = 'Failed to set vCard4: ' + parseErrorIq(iq); console.log(string); spinnerError(spinner_img, string); + vcard_access.disabled = true; } vcard_access.addEventListener('change', function (evt) {