mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-10 17:49:38 +02:00
Add Stanza.setNewStanzaId() and ensureStanzaIdSet()
Also deprecate setStanzaId() since it was not clear if this would create a new stanza ID or just ensure that one is set.
This commit is contained in:
parent
133ee29150
commit
e23babf147
4 changed files with 39 additions and 9 deletions
|
@ -22,7 +22,6 @@ import org.jivesoftware.smack.packet.ExtensionElement;
|
|||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
import org.jivesoftware.smack.packet.id.StanzaIdUtil;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||
|
@ -83,9 +82,7 @@ public class DeliveryReceiptRequest implements ExtensionElement {
|
|||
* @return the Message ID which will be used as receipt ID
|
||||
*/
|
||||
public static String addTo(Message message) {
|
||||
if (message.getStanzaId() == null) {
|
||||
message.setStanzaId(StanzaIdUtil.newStanzaId());
|
||||
}
|
||||
message.ensureStanzaIdSet();
|
||||
message.addExtension(new DeliveryReceiptRequest());
|
||||
return message.getStanzaId();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2014 Florian Schmaus
|
||||
* Copyright 2014-2019 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -27,7 +27,6 @@ import org.jivesoftware.smack.XMPPConnection;
|
|||
import org.jivesoftware.smack.XMPPConnectionRegistry;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.id.StanzaIdUtil;
|
||||
|
||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
import org.jivesoftware.smackx.vcardtemp.packet.VCard;
|
||||
|
@ -105,7 +104,7 @@ public final class VCardManager extends Manager {
|
|||
vcard.setType(IQ.Type.set);
|
||||
// Also make sure to generate a new stanza id (the given vcard could be a vcard result), in which case we don't
|
||||
// want to use the same stanza id again (although it wouldn't break if we did)
|
||||
vcard.setStanzaId(StanzaIdUtil.newStanzaId());
|
||||
vcard.setNewStanzaId();
|
||||
connection().createStanzaCollectorAndSend(vcard).nextResultOrThrow();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue