blob: 0867524bed6ab50edf15365774cbf310ea6c4f52 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
package de.thedevstack.conversationsplus.xmpp.avatar;
import de.thedevstack.conversationsplus.xmpp.pubsub.PubSubPacketParser;
import de.thedevstack.conversationsplus.xml.Element;
import de.thedevstack.conversationsplus.xmpp.stanzas.IqPacket;
/**
* Parses the IQ Packets for handling Avatars
* as defined in XEP-0084.
* @see {@link http://xmpp.org/extensions/xep-0084.html}
*/
public class AvatarPacketParser {
/**
* Extracts the base64 encoded avatar data from an IqPacket.
* @param packet the IqPacket to be parsed.
* @return base64 encoded avatar data
*/
public static String parseAvatarData(IqPacket packet) {
Element items = PubSubPacketParser.findItems(packet);
String base64Avatar = null;
if (null != items) {
Element item = items.findChild("item");
if (null != item) {
base64Avatar = item.findChildContent("data", AvatarPacketGenerator.NAMESPACE_AVATAR_DATA);
}
}
return base64Avatar;
}
}
|