* @param hash The hash.
* @throws rocks.xmpp.core.XmppException If an XMPP exception occurs.
*/
private void publishToVCard(byte[] avatar, String type, String hash) throws XmppException {
VCard vCard = vCardManager.getVCard();
if (avatar != null) {
// Within a given session, a client MUST NOT attempt to upload a given avatar image more than once.
// The client MAY upload the avatar image to the vCard on login and after that MUST NOT upload the vCard again
// unless the user actively changes the avatar image.
if (vCard.getPhoto() == null || !Arrays.equals(vCard.getPhoto().getValue(), avatar)) {
userHashes.put(xmppSession.getConnectedResource().asBareJid(), hash);
// If either there is avatar yet, or the old avatar is different from the new one: update
vCard.setPhoto(new VCard.Image(type, avatar));
vCardManager.setVCard(vCard);
}
} else {
userHashes.put(xmppSession.getConnectedResource().asBareJid(), "");
// If there's currently a photo, we want to reset it.
if (vCard.getPhoto() != null && vCard.getPhoto().getValue() != null) {
vCard.setPhoto(null);
vCardManager.setVCard(vCard);
}
}
}