/** * Adds a collection of stanza extensions to the packet. Does nothing if extensions is null. * * @param extensions a collection of stanza extensions */ public void addExtensions(Collection<ExtensionElement> extensions) { if (extensions == null) return; for (ExtensionElement packetExtension : extensions) { addExtension(packetExtension); } }
public static void addExtensionElement(Stanza packet, XmlPullParser parser, String elementName, String namespace) throws Exception { ExtensionElement packetExtension = parseExtensionElement(elementName, namespace, parser); packet.addExtension(packetExtension); }
/** * Add a reference to another users bare jid to a stanza. * * @param stanza stanza. * @param begin start index of the mention in the messages body. * @param end end index of the mention in the messages body. * @param jid referenced jid. */ public static void addMention(Stanza stanza, int begin, int end, BareJid jid) { URI uri; try { uri = new URI("xmpp:" + jid.toString()); } catch (URISyntaxException e) { throw new AssertionError("Cannot create URI from bareJid."); } ReferenceElement reference = new ReferenceElement(begin, end, ReferenceElement.Type.mention, null, uri); stanza.addExtension(reference); }
/** * Convenience method to add a property to a packet. * * @param packet the stanza to add the property to. * @param name the name of the property to add. * @param value the value of the property to add. */ public static void addProperty(Stanza packet, String name, Object value) { JivePropertiesExtension jpe = (JivePropertiesExtension) packet.getExtension(JivePropertiesExtension.NAMESPACE); if (jpe == null) { jpe = new JivePropertiesExtension(); packet.addExtension(jpe); } jpe.setProperty(name, value); }
/** * Add the given extension and override eventually existing extensions with the same name and * namespace. * * @param extension the extension element to add. * @return one of the removed extensions or <code>null</code> if there are none. * @since 4.1.2 */ public ExtensionElement overrideExtension(ExtensionElement extension) { if (extension == null) return null; synchronized (packetExtensions) { // Note that we need to use removeExtension(String, String) here. If would use // removeExtension(ExtensionElement) then we would remove based on the equality of ExtensionElement, which // is not what we want in this case. ExtensionElement removedExtension = removeExtension(extension.getElementName(), extension.getNamespace()); addExtension(extension); return removedExtension; } }
protected Stanza(Stanza p) { id = p.getStanzaId(); to = p.getTo(); from = p.getFrom(); error = p.error; // Copy extensions for (ExtensionElement pe : p.getExtensions()) { addExtension(pe); } }
packet.addExtension(multipleAddresses);
/** * Adds a collection of stanza extensions to the packet. Does nothing if extensions is null. * * @param extensions a collection of stanza extensions */ public void addExtensions(Collection<ExtensionElement> extensions) { if (extensions == null) return; for (ExtensionElement packetExtension : extensions) { addExtension(packetExtension); } }
public static void addExtensionElement(Stanza packet, XmlPullParser parser, String elementName, String namespace) throws Exception { ExtensionElement packetExtension = parseExtensionElement(elementName, namespace, parser); packet.addExtension(packetExtension); }
/** * Add a reference to another users bare jid to a stanza. * * @param stanza stanza. * @param begin start index of the mention in the messages body. * @param end end index of the mention in the messages body. * @param jid referenced jid. */ public static void addMention(Stanza stanza, int begin, int end, BareJid jid) { URI uri; try { uri = new URI("xmpp:" + jid.toString()); } catch (URISyntaxException e) { throw new AssertionError("Cannot create URI from bareJid."); } ReferenceElement reference = new ReferenceElement(begin, end, ReferenceElement.Type.mention, null, uri); stanza.addExtension(reference); }
mChatMessageListener = new ChatMessageListener() { @Override public void processMessage(Chat chat, Message message) { log.log(Level.INFO, "Received message: " + message.getBody() + " from: " + chat.getParticipant()); if(message != null || !message.getBody().isEmpty()) { DeliveryReceiptManager deliveryReceiptManager = DeliveryReceiptManager.getInstanceFor(mClientConnection); if(DeliveryReceiptManager.hasDeliveryReceiptRequest(message)) { log.log(Level.INFO, "hasDeliveryReceiptRequest == true"); Stanza received = new Message(); received.addExtension(new DeliveryReceipt(message.getStanzaId())); received.setTo(message.getFrom()); try { mClientConnection.sendStanza(received); } catch(NotConnectedException ex) { log.log(Level.SEVERE, "NotConnectedException: " + ex.getMessage()); } catch(Exception ex) { log.log(Level.SEVERE, "Exception: " + ex.getMessage()); } } ......
/** * Add the given extension and override eventually existing extensions with the same name and * namespace. * * @param extension the extension element to add. * @return one of the removed extensions or <code>null</code> if there are none. * @since 4.1.2 */ public ExtensionElement overrideExtension(ExtensionElement extension) { if (extension == null) return null; synchronized (packetExtensions) { // Note that we need to use removeExtension(String, String) here. If would use // removeExtension(ExtensionElement) then we would remove based on the equality of ExtensionElement, which // is not what we want in this case. ExtensionElement removedExtension = removeExtension(extension.getElementName(), extension.getNamespace()); addExtension(extension); return removedExtension; } }
protected Stanza(Stanza p) { id = p.getStanzaId(); to = p.getTo(); from = p.getFrom(); error = p.error; // Copy extensions for (ExtensionElement pe : p.getExtensions()) { addExtension(pe); } }
presencePacketWithSSRC.addExtension(new Nick(this.nickname)); MediaPacketExtension mediaPacket = new MediaPacketExtension(); for(String key : contentMap.keySet()) MediaDirection.SENDRECV.toString()); presencePacketWithSSRC.addExtension(mediaPacket);
presencePacket.addExtension(new Nick(nickname)); connection.sendStanza(presencePacket);