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; } }