1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-10 18:15:58 +01:00

Added ability to set mime type of avatar.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@9526 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Daniel Henninger 2007-11-28 02:55:32 +00:00 committed by dhenninger
parent 13b8d313ba
commit dbac260051

View file

@ -355,6 +355,26 @@ public class VCard extends IQ {
setField("PHOTO", "<TYPE>image/jpeg</TYPE><BINVAL>" + encodedImage + "</BINVAL>", true);
}
/**
* Specify the bytes for the avatar to use as well as the mime type.
*
* @param bytes the bytes of the avatar.
* @param mimeType the mime type of the avatar.
*/
public void setAvatar(byte[] bytes, String mimeType) {
if (bytes == null) {
// Remove avatar (if any) from mappings
otherUnescapableFields.remove("PHOTO");
return;
}
// Otherwise, add to mappings.
String encodedImage = StringUtils.encodeBase64(bytes);
avatar = encodedImage;
setField("PHOTO", "<TYPE>" + mimeType + "</TYPE><BINVAL>" + encodedImage + "</BINVAL>", true);
}
/**
* Set the encoded avatar string. This is used by the provider.
*