1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-09 17:19:39 +02:00

Rename 'Packet' class to 'Stanza'

Smack still uses the term 'Packet' in some places. This is just the
first step towards using correct XMPP terms in Smack.
This commit is contained in:
Florian Schmaus 2015-02-05 11:17:27 +01:00
parent 9fc26f1d83
commit 4698805a34
142 changed files with 595 additions and 572 deletions

View file

@ -40,7 +40,7 @@ import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.filter.ThreadFilter;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Message.Type;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jxmpp.util.XmppStringUtils;
/**
@ -143,7 +143,7 @@ public class ChatManager extends Manager{
// Add a listener for all message packets so that we can deliver
// messages to the best Chat instance available.
connection.addSyncPacketListener(new PacketListener() {
public void processPacket(Packet packet) {
public void processPacket(Stanza packet) {
Message message = (Message) packet;
Chat chat;
if (message.getThread() == null) {

View file

@ -51,7 +51,7 @@ import org.jivesoftware.smack.filter.PacketTypeFilter;
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.XMPPError;
import org.jivesoftware.smack.packet.XMPPError.Condition;
@ -1140,7 +1140,7 @@ public class Roster extends Manager {
}
@Override
public void processPacket(Packet packet) throws NotConnectedException {
public void processPacket(Stanza packet) throws NotConnectedException {
final XMPPConnection connection = connection();
Presence presence = (Presence) packet;
String from = presence.getFrom();
@ -1246,7 +1246,7 @@ public class Roster extends Manager {
private class RosterResultListener implements PacketListener {
@Override
public void processPacket(Packet packet) {
public void processPacket(Stanza packet) {
final XMPPConnection connection = connection();
LOGGER.fine("RosterResultListener received stanza");
Collection<String> addedEntries = new ArrayList<String>();

View file

@ -18,7 +18,7 @@
package org.jivesoftware.smack.roster.packet;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.util.XmlStringBuilder;
import java.util.ArrayList;
@ -220,7 +220,7 @@ public class RosterPacket extends IQ {
public XmlStringBuilder toXML() {
XmlStringBuilder xml = new XmlStringBuilder();
xml.halfOpenElement(Packet.ITEM).attribute("jid", user);
xml.halfOpenElement(Stanza.ITEM).attribute("jid", user);
xml.optAttribute("name", name);
xml.optAttribute("subscription", itemType);
xml.optAttribute("ask", itemStatus);
@ -229,7 +229,7 @@ public class RosterPacket extends IQ {
for (String groupName : groupNames) {
xml.openElement(GROUP).escape(groupName).closeElement(GROUP);
}
xml.closeElement(Packet.ITEM);
xml.closeElement(Stanza.ITEM);
return xml;
}

View file

@ -27,7 +27,7 @@ import org.jivesoftware.smack.DummyConnection;
import org.jivesoftware.smack.chat.ChatManager.MatchMode;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Message.Type;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.test.util.WaitForPacketListener;
import org.junit.After;
import org.junit.Before;
@ -140,7 +140,7 @@ public class ChatConnectionTest {
TestMessageListener msgListener = new TestMessageListener();
TestChatManagerListener listener = new TestChatManagerListener(msgListener);
cm.addChatListener(listener);
Packet incomingChat = createChatPacket(null, true);
Stanza incomingChat = createChatPacket(null, true);
processServerMessage(incomingChat);
Chat newChat = listener.getNewChat();
assertNotNull(newChat);
@ -162,7 +162,7 @@ public class ChatConnectionTest {
TestChatManagerListener listener = new TestChatManagerListener(msgListener);
cm.setMatchMode(MatchMode.SUPPLIED_JID);
cm.addChatListener(listener);
Packet incomingChat = createChatPacket(null, true);
Stanza incomingChat = createChatPacket(null, true);
processServerMessage(incomingChat);
Chat newChat = listener.getNewChat();
assertNotNull(newChat);
@ -188,7 +188,7 @@ public class ChatConnectionTest {
TestChatManagerListener listener = new TestChatManagerListener(msgListener);
cm.setMatchMode(MatchMode.NONE);
cm.addChatListener(listener);
Packet incomingChat = createChatPacket(null, true);
Stanza incomingChat = createChatPacket(null, true);
processServerMessage(incomingChat);
Chat newChat = listener.getNewChat();
assertNotNull(newChat);
@ -221,7 +221,7 @@ public class ChatConnectionTest {
public void chatFoundWhenNoThreadFullJid() {
Chat outgoing = cm.createChat("you@testserver", null);
Packet incomingChat = createChatPacket(null, true);
Stanza incomingChat = createChatPacket(null, true);
processServerMessage(incomingChat);
Chat newChat = listener.getNewChat();
@ -237,7 +237,7 @@ public class ChatConnectionTest {
public void chatFoundWhenNoThreadBaseJid() {
Chat outgoing = cm.createChat("you@testserver", null);
Packet incomingChat = createChatPacket(null, false);
Stanza incomingChat = createChatPacket(null, false);
processServerMessage(incomingChat);
Chat newChat = listener.getNewChat();
@ -253,7 +253,7 @@ public class ChatConnectionTest {
public void chatFoundWithSameThreadFullJid() {
Chat outgoing = cm.createChat("you@testserver", null);
Packet incomingChat = createChatPacket(outgoing.getThreadID(), true);
Stanza incomingChat = createChatPacket(outgoing.getThreadID(), true);
processServerMessage(incomingChat);
Chat newChat = listener.getNewChat();
@ -269,7 +269,7 @@ public class ChatConnectionTest {
public void chatFoundWithSameThreadBaseJid() {
Chat outgoing = cm.createChat("you@testserver", null);
Packet incomingChat = createChatPacket(outgoing.getThreadID(), false);
Stanza incomingChat = createChatPacket(outgoing.getThreadID(), false);
processServerMessage(incomingChat);
Chat newChat = listener.getNewChat();
@ -285,7 +285,7 @@ public class ChatConnectionTest {
public void chatNotFoundWithDiffThreadBaseJid() {
Chat outgoing = cm.createChat("you@testserver", null);
Packet incomingChat = createChatPacket(outgoing.getThreadID() + "ff", false);
Stanza incomingChat = createChatPacket(outgoing.getThreadID() + "ff", false);
processServerMessage(incomingChat);
Chat newChat = listener.getNewChat();
@ -301,7 +301,7 @@ public class ChatConnectionTest {
public void chatNotFoundWithDiffThreadFullJid() {
Chat outgoing = cm.createChat("you@testserver", null);
Packet incomingChat = createChatPacket(outgoing.getThreadID() + "ff", true);
Stanza incomingChat = createChatPacket(outgoing.getThreadID() + "ff", true);
processServerMessage(incomingChat);
Chat newChat = listener.getNewChat();
@ -328,7 +328,7 @@ public class ChatConnectionTest {
return chatMsg;
}
private void processServerMessage(Packet incomingChat) {
private void processServerMessage(Stanza incomingChat) {
TestChatServer chatServer = new TestChatServer(incomingChat, dc);
chatServer.start();
try {
@ -365,10 +365,10 @@ public class ChatConnectionTest {
}
private class TestChatServer extends Thread {
private Packet chatPacket;
private Stanza chatPacket;
private DummyConnection con;
TestChatServer(Packet chatMsg, DummyConnection conect) {
TestChatServer(Stanza chatMsg, DummyConnection conect) {
chatPacket = chatMsg;
con = conect;
}

View file

@ -37,7 +37,7 @@ import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.im.InitSmackIm;
import org.jivesoftware.smack.packet.ErrorIQ;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.XMPPError.Condition;
@ -374,13 +374,13 @@ public class RosterTest extends InitSmackIm {
packet.setFrom("mallory@example.com");
packet.addRosterItem(new Item("spam@example.com", "Cool products!"));
final String requestId = packet.getPacketID();
final String requestId = packet.getStanzaId();
// Simulate receiving the roster push
connection.processPacket(packet);
// Smack should reply with an error IQ
ErrorIQ errorIQ = (ErrorIQ) connection.getSentPacket();
assertEquals(requestId, errorIQ.getPacketID());
assertEquals(requestId, errorIQ.getStanzaId());
assertEquals(Condition.service_unavailable, errorIQ.getError().getCondition());
assertNull("Contact was added to roster", Roster.getInstanceFor(connection).getEntry("spam@example.com"));
@ -537,7 +537,7 @@ public class RosterTest extends InitSmackIm {
private void initRoster() throws InterruptedException, XMPPException, SmackException {
roster.reload();
while (true) {
final Packet sentPacket = connection.getSentPacket();
final Stanza sentPacket = connection.getSentPacket();
if (sentPacket instanceof RosterPacket && ((IQ) sentPacket).getType() == Type.get) {
// setup the roster get request
final RosterPacket rosterRequest = (RosterPacket) sentPacket;
@ -549,7 +549,7 @@ public class RosterTest extends InitSmackIm {
final RosterPacket rosterResult = new RosterPacket();
rosterResult.setTo(connection.getUser());
rosterResult.setType(Type.result);
rosterResult.setPacketID(rosterRequest.getPacketID());
rosterResult.setStanzaId(rosterRequest.getStanzaId());
// prepare romeo's roster entry
final Item romeo = new Item("romeo@example.net", "Romeo");
@ -655,7 +655,7 @@ public class RosterTest extends InitSmackIm {
public void run() {
try {
while (true) {
final Packet packet = connection.getSentPacket();
final Stanza packet = connection.getSentPacket();
if (packet instanceof RosterPacket && ((IQ) packet).getType() == Type.set) {
final RosterPacket rosterRequest = (RosterPacket) packet;

View file

@ -32,7 +32,7 @@ import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.ConnectionConfiguration.Builder;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.roster.RosterTest.TestRosterListener;
import org.jivesoftware.smack.roster.packet.RosterPacket;
import org.jivesoftware.smack.roster.packet.RosterPacket.Item;
@ -137,11 +137,11 @@ public class RosterVersioningTest {
// We expect that the roster request is the only packet sent. This is not part of the specification,
// but a shortcut in the test implementation.
Packet sentPacket = connection.getSentPacket();
Stanza sentPacket = connection.getSentPacket();
if (sentPacket instanceof RosterPacket) {
RosterPacket sentRP = (RosterPacket)sentPacket;
RosterPacket answer = new RosterPacket();
answer.setPacketID(sentRP.getPacketID());
answer.setStanzaId(sentRP.getStanzaId());
answer.setType(Type.result);
answer.setTo(sentRP.getFrom());
@ -249,7 +249,7 @@ public class RosterVersioningTest {
private void answerWithEmptyRosterResult() throws InterruptedException {
// We expect that the roster request is the only packet sent. This is not part of the specification,
// but a shortcut in the test implementation.
Packet sentPacket = connection.getSentPacket();
Stanza sentPacket = connection.getSentPacket();
if (sentPacket instanceof RosterPacket) {
final IQ emptyIQ = IQ.createResultIQ((RosterPacket)sentPacket);
connection.processPacket(emptyIQ);