1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-25 20:18:00 +01:00

Add publish methods without size

This commit is contained in:
Paul Schaub 2019-08-31 17:07:33 +02:00
parent 6b4e2c3842
commit df41a4dc9a

View file

@ -203,6 +203,24 @@ public final class UserAvatarManager extends Manager {
return pepManager.getPepPubSubManager().getOrCreateLeafNode(METADATA_NAMESPACE);
}
/**
* Publish a PNG avatar and its metadata to PubSub.
* If you know what the dimensions of the image are, use {@link #publishPNGAvatar(byte[], int, int)} instead.
*
* @param data raw bytes of the avatar
*
* @throws XMPPErrorException if a protocol level error occurs
* @throws PubSubException.NotALeafNodeException if either the metadata node or the data node is not a
* {@link LeafNode}
* @throws NotConnectedException if the connection is not connected
* @throws InterruptedException if the thread is interrupted
* @throws NoResponseException if the server does not respond
*/
public void publishPNGAvatar(byte[] data) throws XMPPErrorException, PubSubException.NotALeafNodeException,
NotConnectedException, InterruptedException, NoResponseException {
publishPNGAvatar(data, 0, 0);
}
/**
* Publish a PNG Avatar and its metadata to PubSub.
*
@ -224,6 +242,25 @@ public final class UserAvatarManager extends Manager {
publishPNGAvatarMetadata(id, data.length, height, width);
}
/**
* Publish a PNG avatar and its metadata to PubSub.
* If you know the dimensions of the image, use {@link #publishPNGAvatar(File, int, int)} instead.
*
* @param pngFile PNG File
*
* @throws IOException if an {@link IOException} occurs while reading the file
* @throws XMPPErrorException if a protocol level error occurs
* @throws PubSubException.NotALeafNodeException if either the metadata node or the data node is not a valid
* {@link LeafNode}
* @throws NotConnectedException if the connection is not connected
* @throws InterruptedException if the thread is interrupted
* @throws NoResponseException if the server does not respond
*/
public void publishPNGAvatar(File pngFile) throws NotConnectedException, InterruptedException,
PubSubException.NotALeafNodeException, NoResponseException, IOException, XMPPErrorException {
publishPNGAvatar(pngFile, 0, 0);
}
/**
* Publish a PNG avatar and its metadata to PubSub.
*
@ -298,7 +335,8 @@ public final class UserAvatarManager extends Manager {
}
private String publishPNGAvatarData(byte[] data)
throws NoResponseException, NotConnectedException, XMPPErrorException, InterruptedException, PubSubException.NotALeafNodeException {
throws NoResponseException, NotConnectedException, XMPPErrorException, InterruptedException,
PubSubException.NotALeafNodeException {
String itemId = Base64.encodeToString(SHA1.bytes(data));
publishAvatarData(data, itemId);
return itemId;