mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-30 02:02:06 +01:00
Unable to remove avatar in current model. This is now fixed.
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@7084 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
5d30c8ac26
commit
76087c3928
1 changed files with 16 additions and 10 deletions
|
@ -149,12 +149,12 @@ public class VCard extends IQ {
|
||||||
* Set generic, unescapable VCard field. If unescabale is set to true, XML maybe a part of the
|
* Set generic, unescapable VCard field. If unescabale is set to true, XML maybe a part of the
|
||||||
* value.
|
* value.
|
||||||
*
|
*
|
||||||
* @param value value of field
|
* @param value value of field
|
||||||
* @param field field to set. See {@link #getField(String)}
|
* @param field field to set. See {@link #getField(String)}
|
||||||
* @param isUnescapable True if the value should not be escaped, and false if it should.
|
* @param isUnescapable True if the value should not be escaped, and false if it should.
|
||||||
*/
|
*/
|
||||||
public void setField(String field, String value, boolean isUnescapable) {
|
public void setField(String field, String value, boolean isUnescapable) {
|
||||||
if(!isUnescapable) {
|
if (!isUnescapable) {
|
||||||
otherSimpleFields.put(field, value);
|
otherSimpleFields.put(field, value);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -333,10 +333,7 @@ public class VCard extends IQ {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
String encodedImage = StringUtils.encodeBase64(bytes);
|
setAvatar(bytes);
|
||||||
avatar = encodedImage;
|
|
||||||
|
|
||||||
setField("PHOTO", "<TYPE>image/jpeg</TYPE><BINVAL>" + encodedImage + "</BINVAL>", true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -345,6 +342,13 @@ public class VCard extends IQ {
|
||||||
* @param bytes the bytes of the avatar.
|
* @param bytes the bytes of the avatar.
|
||||||
*/
|
*/
|
||||||
public void setAvatar(byte[] bytes) {
|
public void setAvatar(byte[] bytes) {
|
||||||
|
if (bytes == null) {
|
||||||
|
// Remove avatar (if any) from mappings
|
||||||
|
otherUnescapableFields.remove("PHOTO");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, add to mappings.
|
||||||
String encodedImage = StringUtils.encodeBase64(bytes);
|
String encodedImage = StringUtils.encodeBase64(bytes);
|
||||||
avatar = encodedImage;
|
avatar = encodedImage;
|
||||||
|
|
||||||
|
@ -413,12 +417,13 @@ public class VCard extends IQ {
|
||||||
int bytes = (int) file.length();
|
int bytes = (int) file.length();
|
||||||
byte[] buffer = new byte[bytes];
|
byte[] buffer = new byte[bytes];
|
||||||
int readBytes = bis.read(buffer);
|
int readBytes = bis.read(buffer);
|
||||||
if(readBytes != buffer.length) {
|
if (readBytes != buffer.length) {
|
||||||
throw new IOException("Entire file not read");
|
throw new IOException("Entire file not read");
|
||||||
}
|
}
|
||||||
return buffer;
|
return buffer;
|
||||||
} finally {
|
}
|
||||||
if(bis != null) {
|
finally {
|
||||||
|
if (bis != null) {
|
||||||
bis.close();
|
bis.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -467,6 +472,7 @@ public class VCard extends IQ {
|
||||||
* and not anonymous.<p>
|
* and not anonymous.<p>
|
||||||
* <p/>
|
* <p/>
|
||||||
* NOTE: the method is asynchronous and does not wait for the returned value.
|
* NOTE: the method is asynchronous and does not wait for the returned value.
|
||||||
|
*
|
||||||
* @param connection the XMPPConnection to use.
|
* @param connection the XMPPConnection to use.
|
||||||
* @throws XMPPException thrown if there was an issue setting the VCard in the server.
|
* @throws XMPPException thrown if there was an issue setting the VCard in the server.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue