Skip to content

Commit 02f59df

Browse files
committed
Add publish methods without size
1 parent 7426a7b commit 02f59df

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

smack-extensions/src/main/java/org/jivesoftware/smackx/avatar/UserAvatarManager.java

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,24 @@ private LeafNode getOrCreateMetadataNode()
203203
return pepManager.getPepPubSubManager().getOrCreateLeafNode(METADATA_NAMESPACE);
204204
}
205205

206+
/**
207+
* Publish a PNG avatar and its metadata to PubSub.
208+
* If you know what the dimensions of the image are, use {@link #publishPNGAvatar(byte[], int, int)} instead.
209+
*
210+
* @param data raw bytes of the avatar
211+
*
212+
* @throws XMPPErrorException if a protocol level error occurs
213+
* @throws PubSubException.NotALeafNodeException if either the metadata node or the data node is not a
214+
* {@link LeafNode}
215+
* @throws NotConnectedException if the connection is not connected
216+
* @throws InterruptedException if the thread is interrupted
217+
* @throws NoResponseException if the server does not respond
218+
*/
219+
public void publishPNGAvatar(byte[] data) throws XMPPErrorException, PubSubException.NotALeafNodeException,
220+
NotConnectedException, InterruptedException, NoResponseException {
221+
publishPNGAvatar(data, 0, 0);
222+
}
223+
206224
/**
207225
* Publish a PNG Avatar and its metadata to PubSub.
208226
*
@@ -224,6 +242,25 @@ public void publishPNGAvatar(byte[] data, int height, int width)
224242
publishPNGAvatarMetadata(id, data.length, height, width);
225243
}
226244

245+
/**
246+
* Publish a PNG avatar and its metadata to PubSub.
247+
* If you know the dimensions of the image, use {@link #publishPNGAvatar(File, int, int)} instead.
248+
*
249+
* @param pngFile PNG File
250+
*
251+
* @throws IOException if an {@link IOException} occurs while reading the file
252+
* @throws XMPPErrorException if a protocol level error occurs
253+
* @throws PubSubException.NotALeafNodeException if either the metadata node or the data node is not a valid
254+
* {@link LeafNode}
255+
* @throws NotConnectedException if the connection is not connected
256+
* @throws InterruptedException if the thread is interrupted
257+
* @throws NoResponseException if the server does not respond
258+
*/
259+
public void publishPNGAvatar(File pngFile) throws NotConnectedException, InterruptedException,
260+
PubSubException.NotALeafNodeException, NoResponseException, IOException, XMPPErrorException {
261+
publishPNGAvatar(pngFile, 0, 0);
262+
}
263+
227264
/**
228265
* Publish a PNG avatar and its metadata to PubSub.
229266
*
@@ -298,7 +335,8 @@ public byte[] fetchAvatarFromPubSub(EntityBareJid from, MetadataInfo metadataInf
298335
}
299336

300337
private String publishPNGAvatarData(byte[] data)
301-
throws NoResponseException, NotConnectedException, XMPPErrorException, InterruptedException, PubSubException.NotALeafNodeException {
338+
throws NoResponseException, NotConnectedException, XMPPErrorException, InterruptedException,
339+
PubSubException.NotALeafNodeException {
302340
String itemId = Base64.encodeToString(SHA1.bytes(data));
303341
publishAvatarData(data, itemId);
304342
return itemId;

0 commit comments

Comments
 (0)