mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-10 17:49:38 +02:00
SMACK-413 fixed vCard parsing regarding the PHOTO element. Moved vCard test cases to unit-test where appropriate. Added testcases for vCard PHOTO parsing.
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/branches/smack_3_3_0@13586 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
374a12b73a
commit
07a0b8f722
5 changed files with 197 additions and 52 deletions
|
@ -114,7 +114,7 @@ public class VCardProvider implements IQProvider {
|
|||
vCard.setFirstName(getTagContents("GIVEN"));
|
||||
vCard.setLastName(getTagContents("FAMILY"));
|
||||
vCard.setMiddleName(getTagContents("MIDDLE"));
|
||||
vCard.setEncodedImage(getTagContents("BINVAL"));
|
||||
setupPhoto();
|
||||
|
||||
setupEmails();
|
||||
|
||||
|
@ -127,6 +127,41 @@ public class VCardProvider implements IQProvider {
|
|||
setupAddresses();
|
||||
}
|
||||
|
||||
private void setupPhoto() {
|
||||
String binval = null;
|
||||
String mimetype = null;
|
||||
|
||||
NodeList photo = document.getElementsByTagName("PHOTO");
|
||||
if (photo.getLength() != 1)
|
||||
return;
|
||||
|
||||
Node photoNode = photo.item(0);
|
||||
NodeList childNodes = photoNode.getChildNodes();
|
||||
|
||||
int childNodeCount = childNodes.getLength();
|
||||
List<Node> nodes = new ArrayList<Node>(childNodeCount);
|
||||
for (int i = 0; i < childNodeCount; i++)
|
||||
nodes.add(childNodes.item(i));
|
||||
|
||||
String name = null;
|
||||
String value = null;
|
||||
for (Node n : nodes) {
|
||||
name = n.getNodeName();
|
||||
value = n.getTextContent();
|
||||
if (name.equals("BINVAL")) {
|
||||
binval = value;
|
||||
}
|
||||
else if (name.equals("TYPE")) {
|
||||
mimetype = value;
|
||||
}
|
||||
}
|
||||
|
||||
if (binval == null || mimetype == null)
|
||||
return;
|
||||
|
||||
vCard.setAvatar(binval, mimetype);
|
||||
}
|
||||
|
||||
private void setupEmails() {
|
||||
NodeList nodes = document.getElementsByTagName("USERID");
|
||||
if (nodes == null) return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue