powered by Jive Software

VCardProvider

I use Smack 2.1.0 with WildFire 2.4.0 and Psi 0.9.3. VCards, published by Psi, do not recognized by VCardProvider correctly. For my purposes i have made following changes:

  1. setupPhones() method now works with

published by Psi:

private void setupPhones() {

NodeList allPhones = document.getElementsByTagName(“TEL”);

for (int i = 0; i < allPhones.getLength(); i++) {

NodeList nodes = allPhones.item(i).getChildNodes();

String type = null;

String code = null;

String value = null;

for (int j = 0; j < nodes.getLength(); j++) {

Node node = nodes.item(j);

if (node.getNodeType() != Node.ELEMENT_NODE) continue;

if (“NUMBER”.equals(node.getNodeName())) {

value = getTextContent(node);

} else if (“HOME”.equals(node.getNodeName())

|| “WORK”.equals(node.getNodeName())) {

type = node.getNodeName();

} else {

code = node.getNodeName();

}

}

if (code == null || value == null) continue;

if (“HOME”.equals(type)) {

vCard.setPhoneHome(code, value);

} else if (“WORK”.equals(type)) {

vCard.setPhoneWork(code, value);

}

}

}

  1. in initializeFields() method instead of

setupPhones(“WORK”, true);

setupPhones(“HOME”, false);

now just

setupPhones();

I think, the same can be done with setupAddress(…)

  1. Also I need “FN” field, therefore I have commented line:

if (“FN”.equals(element.getNodeName())) continue;

in setupSimpleFields() method. Why this field is skiped?

If you interested in such fixes, I can send you my sources.

Respectfully

Alexander

Hi,

I’‘m the author of current Smack’‘s VCard implementation. I’‘ve prepared another, more robust version of VCardProvider and added your changes (with minor modifications) into it. I’'ve made HOME/WORK tags optional for TEL, and did the same for ADDRESS.

I’‘ll try to publish the changes in Smack codebase in the near time, if I’'ll get access ).

Thanks a lot for the contribution.

Kind regards,

KIR

Thank you, Kirill !

Respectfully

Alexander