mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-12-08 12:01:09 +01:00
Add XMPPConnection.sendStanza(Stanza)
and deprecate sendPacket().
This commit is contained in:
parent
183af99ffb
commit
ed4fa3390f
58 changed files with 183 additions and 167 deletions
|
|
@ -102,7 +102,7 @@ public class MultipleRecipientManager {
|
|||
&& StringUtils.isNullOrEmpty(replyTo) && StringUtils.isNullOrEmpty(replyRoom)) {
|
||||
String toJid = to.iterator().next();
|
||||
packet.setTo(toJid);
|
||||
connection.sendPacket(packet);
|
||||
connection.sendStanza(packet);
|
||||
return;
|
||||
}
|
||||
String serviceAddress = getMultipleRecipienServiceAddress(connection);
|
||||
|
|
@ -155,7 +155,7 @@ public class MultipleRecipientManager {
|
|||
if (replyAddress != null && replyAddress.getJid() != null) {
|
||||
// Send reply to the reply_to address
|
||||
reply.setTo(replyAddress.getJid());
|
||||
connection.sendPacket(reply);
|
||||
connection.sendStanza(reply);
|
||||
}
|
||||
else {
|
||||
// Send reply to multiple recipients
|
||||
|
|
@ -203,19 +203,19 @@ public class MultipleRecipientManager {
|
|||
if (to != null) {
|
||||
for (String jid : to) {
|
||||
packet.setTo(jid);
|
||||
connection.sendPacket(new PacketCopy(packet.toXML()));
|
||||
connection.sendStanza(new PacketCopy(packet.toXML()));
|
||||
}
|
||||
}
|
||||
if (cc != null) {
|
||||
for (String jid : cc) {
|
||||
packet.setTo(jid);
|
||||
connection.sendPacket(new PacketCopy(packet.toXML()));
|
||||
connection.sendStanza(new PacketCopy(packet.toXML()));
|
||||
}
|
||||
}
|
||||
if (bcc != null) {
|
||||
for (String jid : bcc) {
|
||||
packet.setTo(jid);
|
||||
connection.sendPacket(new PacketCopy(packet.toXML()));
|
||||
connection.sendStanza(new PacketCopy(packet.toXML()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -258,7 +258,7 @@ public class MultipleRecipientManager {
|
|||
// Add extension to packet
|
||||
packet.addExtension(multipleAddresses);
|
||||
// Send the packet
|
||||
connection.sendPacket(packet);
|
||||
connection.sendStanza(packet);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -442,7 +442,7 @@ public class InBandBytestreamManager implements BytestreamManager {
|
|||
protected void replyRejectPacket(IQ request) throws NotConnectedException {
|
||||
XMPPError xmppError = new XMPPError(XMPPError.Condition.not_acceptable);
|
||||
IQ error = IQ.createErrorResponse(request, xmppError);
|
||||
this.connection.sendPacket(error);
|
||||
this.connection.sendStanza(error);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -455,7 +455,7 @@ public class InBandBytestreamManager implements BytestreamManager {
|
|||
protected void replyResourceConstraintPacket(IQ request) throws NotConnectedException {
|
||||
XMPPError xmppError = new XMPPError(XMPPError.Condition.resource_constraint);
|
||||
IQ error = IQ.createErrorResponse(request, xmppError);
|
||||
this.connection.sendPacket(error);
|
||||
this.connection.sendStanza(error);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -468,7 +468,7 @@ public class InBandBytestreamManager implements BytestreamManager {
|
|||
protected void replyItemNotFoundPacket(IQ request) throws NotConnectedException {
|
||||
XMPPError xmppError = new XMPPError(XMPPError.Condition.item_not_found);
|
||||
IQ error = IQ.createErrorResponse(request, xmppError);
|
||||
this.connection.sendPacket(error);
|
||||
this.connection.sendStanza(error);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ public class InBandBytestreamRequest implements BytestreamRequest {
|
|||
|
||||
// acknowledge request
|
||||
IQ resultIQ = IQ.createResultIQ(this.byteStreamRequest);
|
||||
connection.sendPacket(resultIQ);
|
||||
connection.sendStanza(resultIQ);
|
||||
|
||||
return ibbSession;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
|
||||
// acknowledge close request
|
||||
IQ confirmClose = IQ.createResultIQ(closeRequest);
|
||||
this.connection.sendPacket(confirmClose);
|
||||
this.connection.sendStanza(confirmClose);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -457,7 +457,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
if (data.getSeq() <= this.lastSequence) {
|
||||
IQ unexpectedRequest = IQ.createErrorResponse((IQ) packet, new XMPPError(
|
||||
XMPPError.Condition.unexpected_request));
|
||||
connection.sendPacket(unexpectedRequest);
|
||||
connection.sendStanza(unexpectedRequest);
|
||||
return;
|
||||
|
||||
}
|
||||
|
|
@ -467,7 +467,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
// data is invalid; respond with bad-request error
|
||||
IQ badRequest = IQ.createErrorResponse((IQ) packet, new XMPPError(
|
||||
XMPPError.Condition.bad_request));
|
||||
connection.sendPacket(badRequest);
|
||||
connection.sendStanza(badRequest);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -476,7 +476,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
|
||||
// confirm IQ
|
||||
IQ confirmData = IQ.createResultIQ((IQ) packet);
|
||||
connection.sendPacket(confirmData);
|
||||
connection.sendStanza(confirmData);
|
||||
|
||||
// set last seen sequence
|
||||
this.lastSequence = data.getSeq();
|
||||
|
|
@ -808,7 +808,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
Message message = new Message(remoteJID);
|
||||
message.addExtension(data);
|
||||
|
||||
connection.sendPacket(message);
|
||||
connection.sendStanza(message);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -704,7 +704,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
|
|||
protected void replyRejectPacket(IQ packet) throws NotConnectedException {
|
||||
XMPPError xmppError = new XMPPError(XMPPError.Condition.not_acceptable);
|
||||
IQ errorIQ = IQ.createErrorResponse(packet, xmppError);
|
||||
this.connection.sendPacket(errorIQ);
|
||||
this.connection.sendStanza(errorIQ);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ public class Socks5BytestreamRequest implements BytestreamRequest {
|
|||
|
||||
// send used-host confirmation
|
||||
Bytestream response = createUsedHostResponse(selectedHost);
|
||||
this.manager.getConnection().sendPacket(response);
|
||||
this.manager.getConnection().sendStanza(response);
|
||||
|
||||
return new Socks5BytestreamSession(socket, selectedHost.getJID().equals(
|
||||
this.bytestreamRequest.getFrom()));
|
||||
|
|
@ -282,7 +282,7 @@ public class Socks5BytestreamRequest implements BytestreamRequest {
|
|||
String errorMessage = "Could not establish socket with any provided host";
|
||||
XMPPError error = XMPPError.from(XMPPError.Condition.item_not_found, errorMessage);
|
||||
IQ errorIQ = IQ.createErrorResponse(this.bytestreamRequest, error);
|
||||
this.manager.getConnection().sendPacket(errorIQ);
|
||||
this.manager.getConnection().sendStanza(errorIQ);
|
||||
throw new XMPPErrorException(errorMessage, error);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -505,7 +505,7 @@ public class EntityCapsManager extends Manager {
|
|||
if (connection != null && connection.isAuthenticated() && presenceSend) {
|
||||
Presence presence = new Presence(Presence.Type.available);
|
||||
try {
|
||||
connection.sendPacket(presence);
|
||||
connection.sendStanza(presence);
|
||||
}
|
||||
catch (NotConnectedException e) {
|
||||
LOGGER.log(Level.WARNING, "Could could not update presence with caps info", e);
|
||||
|
|
|
|||
|
|
@ -173,6 +173,6 @@ public class FileTransferManager extends Manager {
|
|||
// Socks5BytestreamManager.replyRejectPacket(IQ).
|
||||
IQ rejection = IQ.createErrorResponse(initiation, new XMPPError(
|
||||
XMPPError.Condition.forbidden));
|
||||
connection().sendPacket(rejection);
|
||||
connection().sendStanza(rejection);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ public class FileTransferNegotiator extends Manager {
|
|||
String errorMessage = "No stream methods contained in stanza.";
|
||||
XMPPError error = XMPPError.from(XMPPError.Condition.bad_request, errorMessage);
|
||||
IQ iqPacket = IQ.createErrorResponse(si, error);
|
||||
connection().sendPacket(iqPacket);
|
||||
connection().sendStanza(iqPacket);
|
||||
throw new FileTransferException.NoStreamMethodsOfferedException();
|
||||
}
|
||||
|
||||
|
|
@ -203,7 +203,7 @@ public class FileTransferNegotiator extends Manager {
|
|||
}
|
||||
catch (NoAcceptableTransferMechanisms e) {
|
||||
IQ iqPacket = IQ.createErrorResponse(si, XMPPError.from(XMPPError.Condition.bad_request, "No acceptable transfer mechanism"));
|
||||
connection().sendPacket(iqPacket);
|
||||
connection().sendStanza(iqPacket);
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ public abstract class StreamNegotiator {
|
|||
streamMethodInitiation = initationSetEvents.performActionAndWaitForEvent(eventKey, connection.getPacketReplyTimeout(), new Callback<NotConnectedException>() {
|
||||
@Override
|
||||
public void action() throws NotConnectedException {
|
||||
connection.sendPacket(response);
|
||||
connection.sendStanza(response);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -518,7 +518,7 @@ public class MultiUserChat {
|
|||
// field is in the form "roomName@service/nickname"
|
||||
Presence leavePresence = new Presence(Presence.Type.unavailable);
|
||||
leavePresence.setTo(room + "/" + nickname);
|
||||
connection.sendPacket(leavePresence);
|
||||
connection.sendStanza(leavePresence);
|
||||
// Reset occupant information.
|
||||
occupantsMap.clear();
|
||||
nickname = null;
|
||||
|
|
@ -689,7 +689,7 @@ public class MultiUserChat {
|
|||
// Add the MUCUser packet that includes the invitation to the message
|
||||
message.addExtension(mucUser);
|
||||
|
||||
connection.sendPacket(message);
|
||||
connection.sendStanza(message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -892,7 +892,7 @@ public class MultiUserChat {
|
|||
joinPresence.setTo(room + "/" + nickname);
|
||||
|
||||
// Send join packet.
|
||||
connection.sendPacket(joinPresence);
|
||||
connection.sendStanza(joinPresence);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -939,7 +939,7 @@ public class MultiUserChat {
|
|||
form.addField(requestVoiceField);
|
||||
Message message = new Message(room);
|
||||
message.addExtension(form);
|
||||
connection.sendPacket(message);
|
||||
connection.sendStanza(message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1575,7 +1575,7 @@ public class MultiUserChat {
|
|||
public void sendMessage(String text) throws XMPPException, NotConnectedException {
|
||||
Message message = createMessage();
|
||||
message.setBody(text);
|
||||
connection.sendPacket(message);
|
||||
connection.sendStanza(message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1612,7 +1612,7 @@ public class MultiUserChat {
|
|||
public void sendMessage(Message message) throws XMPPException, NotConnectedException {
|
||||
message.setTo(room);
|
||||
message.setType(Message.Type.groupchat);
|
||||
connection.sendPacket(message);
|
||||
connection.sendStanza(message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -284,7 +284,7 @@ public class MultiUserChatManager extends Manager {
|
|||
// Add the MUCUser packet that includes the rejection
|
||||
message.addExtension(mucUser);
|
||||
|
||||
connection().sendPacket(message);
|
||||
connection().sendStanza(message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||
* Message message = new Message("user@chat.example.com");
|
||||
* message.setBody("Join me for a group chat!");
|
||||
* message.addExtension(new GroupChatInvitation("room@chat.example.com"););
|
||||
* con.sendPacket(message);
|
||||
* con.sendStanza(message);
|
||||
* </pre>
|
||||
*
|
||||
* To listen for group chat invitations, use a StanzaExtensionFilter for the
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ public class PEPManager {
|
|||
//pubSub.setFrom(connection.getUser());
|
||||
|
||||
// Send the message that contains the roster
|
||||
connection.sendPacket(pubSub);
|
||||
connection.sendStanza(pubSub);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -211,7 +211,7 @@ public class LeafNode extends Node
|
|||
{
|
||||
PubSub packet = createPubsubPacket(Type.set, new NodeExtension(PubSubElementType.PUBLISH, getId()));
|
||||
|
||||
con.sendPacket(packet);
|
||||
con.sendStanza(packet);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -256,7 +256,7 @@ public class LeafNode extends Node
|
|||
{
|
||||
PubSub packet = createPubsubPacket(Type.set, new PublishItem<T>(getId(), items));
|
||||
|
||||
con.sendPacket(packet);
|
||||
con.sendStanza(packet);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
|||
* });
|
||||
* Message message = …
|
||||
* DeliveryReceiptRequest.addTo(message);
|
||||
* connection.sendPacket(message);
|
||||
* connection.sendStanza(message);
|
||||
* </pre>
|
||||
*
|
||||
* DeliveryReceiptManager can be configured to automatically add delivery receipt requests to every
|
||||
|
|
@ -158,7 +158,7 @@ public class DeliveryReceiptManager extends Manager {
|
|||
|
||||
final Message messageWithReceiptRequest = (Message) packet;
|
||||
Message ack = receiptMessageFor(messageWithReceiptRequest);
|
||||
connection.sendPacket(ack);
|
||||
connection.sendStanza(ack);
|
||||
}
|
||||
}, MESSAGES_WITH_DEVLIERY_RECEIPT_REQUEST);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue