1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-20 11:02:05 +01:00

Document how an Avatar can be removed from a vCard. Add a convenience method.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@13583 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Florian Schmaus 2013-03-23 00:26:42 +00:00 committed by flow
parent 6aa195eb88
commit ca2f8efe60

View file

@ -338,22 +338,22 @@ public class VCard extends IQ {
}
/**
* Specify the bytes for the avatar to use.
* Removes the avatar from the vCard
*
* @param bytes the bytes of the avatar.
* This is done by setting the PHOTO value to the empty string as defined in XEP-0153
*/
public void setAvatar(byte[] bytes) {
if (bytes == null) {
// Remove avatar (if any) from mappings
otherUnescapableFields.remove("PHOTO");
return;
public void removeAvatar() {
setAvatar(null, "image/jpeg");
}
// Otherwise, add to mappings.
String encodedImage = StringUtils.encodeBase64(bytes);
avatar = encodedImage;
setField("PHOTO", "<TYPE>image/jpeg</TYPE><BINVAL>" + encodedImage + "</BINVAL>", true);
/**
* Specify the bytes for the avatar to use.
* If bytes is null, then the avatar will be removed.
*
* @param bytes the bytes of the avatar, or null to remove the avatar data
*/
public void setAvatar(byte[] bytes) {
setAvatar(bytes, "image/jpeg");
}
/**