/** * Get data form from stanza. * @param packet * @return the DataForm or null */ public static DataForm from(Stanza packet) { return (DataForm) packet.getExtension(ELEMENT, NAMESPACE); }
/** * Get Delayed Delivery information as defined in XEP-91 * <p> * Prefer {@link #getDelayInformation(Stanza)} over this method for backwards compatibility. * </p> * @param packet * @return the Delayed Delivery information or <code>null</code> */ public static DelayInformation getLegacyDelayInformation(Stanza packet) { return packet.getExtension(LEGACY_DELAYED_DELIVERY_ELEMENT, LEGACY_DELAYED_DELIVERY_NAMESPACE); }
/** * Retrieve the GCM stanza extension from the packet. * * @param packet * @return the GCM stanza extension or null. */ public static GcmPacketExtension from(Stanza packet) { return packet.getExtension(ELEMENT, NAMESPACE); } }
/** * Get the group chat invitation from the given stanza. * @param packet * @return the GroupChatInvitation or null */ public static GroupChatInvitation from(Stanza packet) { return packet.getExtension(ELEMENT, NAMESPACE); }
/** * Get the forwarded extension. * @param packet * @return the Forwarded extension or null */ public static Forwarded from(Stanza packet) { return packet.getExtension(ELEMENT, NAMESPACE); }
/** * Retrieve the JSON stanza extension from the packet. * * @param packet * @return the JSON stanza extension or null. */ public static JsonPacketExtension from(Stanza packet) { return packet.getExtension(ELEMENT, NAMESPACE); } }
/** * Return delay information from the given stanza. * * @param packet * @return the DelayInformation or null */ public static DelayInformation from(Stanza packet) { return packet.getExtension(ELEMENT, NAMESPACE); } }
/** * Return the SHIM headers extension of this stanza or null if there is none. * * @param packet * @return the headers extension or null. */ public static HeadersExtension from(Stanza packet) { return packet.getExtension(ELEMENT, NAMESPACE); } }
/** * Retrieve the MUCUser PacketExtension from packet, if any. * * @param packet * @return the MUCUser PacketExtension or {@code null} */ public static MUCUser from(Stanza packet) { return packet.getExtension(ELEMENT, NAMESPACE); }
/** * Get the {@link DeliveryReceiptRequest} extension of the packet, if any. * * @param packet the packet * @return the {@link DeliveryReceiptRequest} extension or {@code null} */ public static DeliveryReceiptRequest from(Stanza packet) { return packet.getExtension(ELEMENT, DeliveryReceipt.NAMESPACE); }
/** * Retrieve the MUCInitialPresence PacketExtension from packet, if any. * * @param packet * @return the MUCInitialPresence PacketExtension or {@code null} */ public static MUCInitialPresence from(Stanza packet) { return packet.getExtension(ELEMENT, NAMESPACE); }
public static CapsExtension from(Stanza stanza) { return stanza.getExtension(ELEMENT, NAMESPACE); } }
public static OpenPgpElement fromStanza(Stanza stanza) { return stanza.getExtension(ELEMENT, NAMESPACE); } }
public static EventElement from(Stanza stanza) { return stanza.getExtension(ELEMENT, NAMESPACE); } }
@Override public boolean accept(Stanza packet) { OfflineMessageInfo info = packet.getExtension("offline", namespace); return nodes.contains(info.getNode()); } });
private static List<String> getSubscriptionIds(Stanza packet) { HeadersExtension headers = packet.getExtension("headers", "http://jabber.org/protocol/shim"); List<String> values = null; if (headers != null) { values = new ArrayList<>(headers.getHeaders().size()); for (Header header : headers.getHeaders()) { values.add(header.getValue()); } } return values; }
@Override public void processStanza(Stanza packet) { EventElement event = packet.getExtension("event", PubSubNamespace.event.getXmlns()); ConfigurationEvent config = (ConfigurationEvent) event.getEvent(); // TODO: Use AsyncButOrdered (with Node as Key?) listener.handleNodeConfiguration(config); } }
/** * Get a {@link ConfigureForm} from a packet. * * @param packet * @param elem * @return The configuration form */ public static ConfigureForm getFormFromPacket(Stanza packet, PubSubElementType elem) { FormNode config = packet.getExtension(elem.getElementName(), elem.getNamespace().getXmlns()); Form formReply = config.getForm(); return new ConfigureForm(formReply); } }
/** * Gets the subscriptions on the root node. * * @return List of exceptions * @throws XMPPErrorException * @throws NoResponseException * @throws NotConnectedException * @throws InterruptedException */ public List<Subscription> getSubscriptions() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { Stanza reply = sendPubsubPacket(Type.get, new NodeExtension(PubSubElementType.SUBSCRIPTIONS), null); SubscriptionsExtension subElem = reply.getExtension(PubSubElementType.SUBSCRIPTIONS.getElementName(), PubSubElementType.SUBSCRIPTIONS.getNamespace().getXmlns()); return subElem.getSubscriptions(); }
@Override @SuppressWarnings({ "rawtypes", "unchecked" }) public void processStanza(Stanza packet) { EventElement event = packet.getExtension("event", PubSubNamespace.event.getXmlns()); ItemsExtension itemsElem = (ItemsExtension) event.getEvent(); ItemPublishEvent eventItems = new ItemPublishEvent(itemsElem.getNode(), itemsElem.getItems(), getSubscriptionIds(packet), DelayInformationManager.getDelayTimestamp(packet)); // TODO: Use AsyncButOrdered (with Node as Key?) listener.handlePublishedItems(eventItems); } }