1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-22 12:02:05 +01:00

Make Workgroup JID an EntityBareJid in smackx.workgroup

This commit is contained in:
Florian Schmaus 2018-04-18 08:48:52 +02:00
parent 96046a063a
commit 5fbf2ce75a
8 changed files with 38 additions and 33 deletions

View file

@ -28,6 +28,7 @@ import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smackx.workgroup.packet.AgentInfo;
import org.jivesoftware.smackx.workgroup.packet.AgentWorkgroups;
import org.jxmpp.jid.EntityBareJid;
import org.jxmpp.jid.Jid;
/**
@ -37,7 +38,7 @@ import org.jxmpp.jid.Jid;
*/
public class Agent {
private XMPPConnection connection;
private Jid workgroupJID;
private final EntityBareJid workgroupJID;
public static Collection<String> getWorkgroups(Jid serviceJID, Jid agentJID, XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
AgentWorkgroups request = new AgentWorkgroups(agentJID);
@ -49,7 +50,7 @@ public class Agent {
/**
* Constructs an Agent.
*/
Agent(XMPPConnection connection, Jid workgroupJID) {
Agent(XMPPConnection connection, EntityBareJid workgroupJID) {
this.connection = connection;
this.workgroupJID = workgroupJID;
}

View file

@ -58,7 +58,7 @@ public class AgentRoster {
private static final int EVENT_PRESENCE_CHANGED = 2;
private final XMPPConnection connection;
private final Jid workgroupJID;
private final EntityBareJid workgroupJID;
private final List<EntityBareJid> entries = new ArrayList<>();
private final List<AgentRosterListener> listeners = new ArrayList<>();
private final Map<Jid, Map<Resourcepart, Presence>> presenceMap = new HashMap<>();
@ -73,7 +73,7 @@ public class AgentRoster {
* @throws NotConnectedException
* @throws InterruptedException
*/
AgentRoster(XMPPConnection connection, Jid workgroupJID) throws NotConnectedException, InterruptedException {
AgentRoster(XMPPConnection connection, EntityBareJid workgroupJID) throws NotConnectedException, InterruptedException {
this.connection = connection;
this.workgroupJID = workgroupJID;
// Listen for any roster packets.
@ -292,7 +292,6 @@ public class AgentRoster {
/**
* Listens for all presence packets and processes them.
*/
@SuppressWarnings("EqualsIncompatibleType")
private class PresencePacketListener implements StanzaListener {
@Override
public void processStanza(Stanza packet) {

View file

@ -76,6 +76,8 @@ import org.jivesoftware.smackx.workgroup.settings.GenericSettings;
import org.jivesoftware.smackx.workgroup.settings.SearchSettings;
import org.jivesoftware.smackx.xdata.Form;
import org.jxmpp.jid.EntityBareJid;
import org.jxmpp.jid.EntityJid;
import org.jxmpp.jid.Jid;
import org.jxmpp.jid.parts.Resourcepart;
import org.jxmpp.stringprep.XmppStringprepException;
@ -96,7 +98,7 @@ public class AgentSession {
private final XMPPConnection connection;
private final Jid workgroupJID;
private final EntityBareJid workgroupJID;
private boolean online = false;
private Presence.Mode presenceMode;
@ -124,7 +126,7 @@ public class AgentSession {
* authentication.
* @param workgroupJID the fully qualified JID of the workgroup.
*/
public AgentSession(Jid workgroupJID, XMPPConnection connection) {
public AgentSession(EntityBareJid workgroupJID, XMPPConnection connection) {
// Login must have been done before passing in connection.
if (!connection.isAuthenticated()) {
throw new IllegalStateException("Must login to server before creating workgroup.");
@ -502,9 +504,9 @@ public class AgentSession {
* @throws NotConnectedException
* @throws InterruptedException
*/
public void dequeueUser(String userID) throws XMPPException, NotConnectedException, InterruptedException {
public void dequeueUser(EntityJid userID) throws XMPPException, NotConnectedException, InterruptedException {
// todo: this method simply won't work right now.
DepartQueuePacket departPacket = new DepartQueuePacket(this.workgroupJID);
DepartQueuePacket departPacket = new DepartQueuePacket(workgroupJID, userID);
// PENDING
this.connection.sendStanza(departPacket);

View file

@ -25,12 +25,13 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smackx.workgroup.packet.Transcript;
import org.jivesoftware.smackx.workgroup.packet.Transcripts;
import org.jxmpp.jid.EntityBareJid;
import org.jxmpp.jid.Jid;
/**
* A TranscriptManager helps to retrieve the full conversation transcript of a given session
* {@link #getTranscript(Jid, String)} or to retrieve a list with the summary of all the
* conversations that a user had {@link #getTranscripts(Jid, Jid)}.
* {@link #getTranscript(EntityBareJid, String)} or to retrieve a list with the summary of all the
* conversations that a user had {@link #getTranscripts(EntityBareJid, Jid)}.
*
* @author Gaston Dombiak
*/
@ -52,7 +53,7 @@ public class TranscriptManager {
* @throws NotConnectedException
* @throws InterruptedException
*/
public Transcript getTranscript(Jid workgroupJID, String sessionID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
public Transcript getTranscript(EntityBareJid workgroupJID, String sessionID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
Transcript request = new Transcript(sessionID);
request.setTo(workgroupJID);
Transcript response = connection.createStanzaCollectorAndSend(request).nextResultOrThrow();
@ -71,7 +72,7 @@ public class TranscriptManager {
* @throws NotConnectedException
* @throws InterruptedException
*/
public Transcripts getTranscripts(Jid workgroupJID, Jid userID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
public Transcripts getTranscripts(EntityBareJid workgroupJID, Jid userID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
Transcripts request = new Transcripts(userID);
request.setTo(workgroupJID);
Transcripts response = connection.createStanzaCollectorAndSend(request).nextResultOrThrow();

View file

@ -28,7 +28,9 @@ import java.util.TimeZone;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.util.ParserUtils;
import org.jxmpp.jid.EntityBareJid;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@ -56,14 +58,14 @@ public class AgentStatus implements ExtensionElement {
*/
public static final String NAMESPACE = "http://jabber.org/protocol/workgroup";
private String workgroupJID;
private EntityBareJid workgroupJID;
private final List<ChatInfo> currentChats = new ArrayList<>();
private int maxChats = -1;
AgentStatus() {
}
public String getWorkgroupJID() {
public EntityBareJid getWorkgroupJID() {
return workgroupJID;
}
@ -238,7 +240,7 @@ public class AgentStatus implements ExtensionElement {
public AgentStatus parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
AgentStatus agentStatus = new AgentStatus();
agentStatus.workgroupJID = parser.getAttributeValue("", "jid");
agentStatus.workgroupJID = ParserUtils.getBareJidAttribute(parser);
boolean done = false;
while (!done) {

View file

@ -19,7 +19,8 @@ package org.jivesoftware.smackx.workgroup.packet;
import org.jivesoftware.smack.packet.IQ;
import org.jxmpp.jid.Jid;
import org.jxmpp.jid.EntityBareJid;
import org.jxmpp.jid.EntityJid;
/**
* A IQ stanza used to depart a workgroup queue. There are two cases for issuing a depart
@ -34,18 +35,14 @@ import org.jxmpp.jid.Jid;
*/
public class DepartQueuePacket extends IQ {
private Jid user;
private DepartQueuePacket() {
super("depart-queue", "http://jabber.org/protocol/workgroup");
}
private final EntityJid user;
/**
* Creates a depart queue request stanza to the specified workgroup.
*
* @param workgroup the workgroup to depart.
*/
public DepartQueuePacket(Jid workgroup) {
public DepartQueuePacket(EntityBareJid workgroup) {
this(workgroup, null);
}
@ -56,8 +53,8 @@ public class DepartQueuePacket extends IQ {
* @param workgroup the workgroup to depart.
* @param user the user to make depart from the queue.
*/
public DepartQueuePacket(Jid workgroup, Jid user) {
this();
public DepartQueuePacket(EntityBareJid workgroup, EntityJid user) {
super("depart-queue", "http://jabber.org/protocol/workgroup");
this.user = user;
setTo(workgroup);

View file

@ -21,7 +21,9 @@ import java.io.IOException;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.util.ParserUtils;
import org.jxmpp.jid.EntityBareJid;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@ -41,13 +43,13 @@ public class WorkgroupInformation implements ExtensionElement {
*/
public static final String NAMESPACE = "http://jabber.org/protocol/workgroup";
private final String workgroupJID;
private final EntityBareJid workgroupJID;
public WorkgroupInformation(String workgroupJID) {
public WorkgroupInformation(EntityBareJid workgroupJID) {
this.workgroupJID = workgroupJID;
}
public String getWorkgroupJID() {
public EntityBareJid getWorkgroupJID() {
return workgroupJID;
}
@ -83,7 +85,7 @@ public class WorkgroupInformation implements ExtensionElement {
public WorkgroupInformation parse(XmlPullParser parser,
int initialDepth) throws XmlPullParserException,
IOException {
String workgroupJID = parser.getAttributeValue("", "jid");
EntityBareJid workgroupJID = ParserUtils.getBareJidAttribute(parser);
// since this is a start and end tag, and we arrive on the start, this should guarantee
// we leave on the end

View file

@ -61,6 +61,7 @@ import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.jxmpp.jid.DomainBareJid;
import org.jxmpp.jid.EntityBareJid;
import org.jxmpp.jid.EntityJid;
import org.jxmpp.jid.Jid;
@ -77,7 +78,7 @@ import org.jxmpp.jid.Jid;
*/
public class Workgroup {
private final Jid workgroupJID;
private final EntityBareJid workgroupJID;
private final XMPPConnection connection;
private boolean inQueue;
private final CopyOnWriteArraySet<WorkgroupInvitationListener> invitationListeners;
@ -96,7 +97,7 @@ public class Workgroup {
* @param connection an XMPP connection which must have already undergone a
* successful login.
*/
public Workgroup(Jid workgroupJID, XMPPConnection connection) {
public Workgroup(EntityBareJid workgroupJID, XMPPConnection connection) {
// Login must have been done before passing in connection.
if (!connection.isAuthenticated()) {
throw new IllegalStateException("Must login to server before creating workgroup.");
@ -163,7 +164,7 @@ public class Workgroup {
*
* @return the name of the workgroup.
*/
public Jid getWorkgroupJID() {
public EntityBareJid getWorkgroupJID() {
return workgroupJID;
}
@ -569,7 +570,7 @@ public class Workgroup {
private final Jid userID;
private final DataForm form;
private JoinQueuePacket(Jid workgroup, Form answerForm, Jid userID) {
private JoinQueuePacket(EntityBareJid workgroup, Form answerForm, Jid userID) {
super("join-queue", "http://jabber.org/protocol/workgroup");
this.userID = userID;