mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-10 17:49:38 +02:00
Use Jid (and subclasses) from jxmpp-jid
Fixes SMACK-634
This commit is contained in:
parent
0ee2d9ed1e
commit
5bb4727c57
180 changed files with 1510 additions and 1032 deletions
|
@ -20,6 +20,8 @@ package org.jivesoftware.smackx.workgroup;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
/**
|
||||
* An immutable class wrapping up the basic information which comprises a group chat invitation.
|
||||
*
|
||||
|
@ -27,14 +29,14 @@ import java.util.Map;
|
|||
*/
|
||||
public class WorkgroupInvitation {
|
||||
|
||||
protected String uniqueID;
|
||||
protected Jid uniqueID;
|
||||
|
||||
protected String sessionID;
|
||||
|
||||
protected String groupChatName;
|
||||
protected String issuingWorkgroupName;
|
||||
protected Jid groupChatName;
|
||||
protected Jid issuingWorkgroupName;
|
||||
protected String messageBody;
|
||||
protected String invitationSender;
|
||||
protected Jid invitationSender;
|
||||
protected Map<String, List<String>> metaData;
|
||||
|
||||
/**
|
||||
|
@ -48,8 +50,8 @@ public class WorkgroupInvitation {
|
|||
* @param msgBody the body of the message which contained the invitation
|
||||
* @param from the user jid who issued the invitation, if known, null otherwise
|
||||
*/
|
||||
public WorkgroupInvitation (String jid, String group, String workgroup,
|
||||
String sessID, String msgBody, String from) {
|
||||
public WorkgroupInvitation (Jid jid, Jid group, Jid workgroup,
|
||||
String sessID, String msgBody, Jid from) {
|
||||
this(jid, group, workgroup, sessID, msgBody, from, null);
|
||||
}
|
||||
|
||||
|
@ -63,8 +65,8 @@ public class WorkgroupInvitation {
|
|||
* @param from the user jid who issued the invitation, if known, null otherwise
|
||||
* @param metaData the metadata sent with the invitation
|
||||
*/
|
||||
public WorkgroupInvitation (String jid, String group, String workgroup, String sessID, String msgBody,
|
||||
String from, Map<String, List<String>> metaData) {
|
||||
public WorkgroupInvitation (Jid jid, Jid group, Jid workgroup, String sessID, String msgBody,
|
||||
Jid from, Map<String, List<String>> metaData) {
|
||||
super();
|
||||
|
||||
this.uniqueID = jid;
|
||||
|
@ -80,7 +82,7 @@ public class WorkgroupInvitation {
|
|||
* @return the jid string with which the issuing AgentSession or Workgroup instance
|
||||
* was created.
|
||||
*/
|
||||
public String getUniqueID () {
|
||||
public Jid getUniqueID () {
|
||||
return this.uniqueID;
|
||||
}
|
||||
|
||||
|
@ -96,14 +98,14 @@ public class WorkgroupInvitation {
|
|||
/**
|
||||
* @return the jid of the room to which the person is invited.
|
||||
*/
|
||||
public String getGroupChatName () {
|
||||
public Jid getGroupChatName () {
|
||||
return this.groupChatName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the workgroup from which the invitation was issued.
|
||||
*/
|
||||
public String getWorkgroupName () {
|
||||
public Jid getWorkgroupName () {
|
||||
return this.issuingWorkgroupName;
|
||||
}
|
||||
|
||||
|
@ -117,7 +119,7 @@ public class WorkgroupInvitation {
|
|||
/**
|
||||
* @return the user who issued the invitation, or null if it wasn't known.
|
||||
*/
|
||||
public String getInvitationSender () {
|
||||
public Jid getInvitationSender () {
|
||||
return this.invitationSender;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
|
|||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
@ -34,9 +35,9 @@ import java.util.Collection;
|
|||
*/
|
||||
public class Agent {
|
||||
private XMPPConnection connection;
|
||||
private String workgroupJID;
|
||||
private Jid workgroupJID;
|
||||
|
||||
public static Collection<String> getWorkgroups(String serviceJID, String agentJID, XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
public static Collection<String> getWorkgroups(Jid serviceJID, Jid agentJID, XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
AgentWorkgroups request = new AgentWorkgroups(agentJID);
|
||||
request.setTo(serviceJID);
|
||||
AgentWorkgroups response = (AgentWorkgroups) connection.createPacketCollectorAndSend(request).nextResultOrThrow();
|
||||
|
@ -46,7 +47,7 @@ public class Agent {
|
|||
/**
|
||||
* Constructs an Agent.
|
||||
*/
|
||||
Agent(XMPPConnection connection, String workgroupJID) {
|
||||
Agent(XMPPConnection connection, Jid workgroupJID) {
|
||||
this.connection = connection;
|
||||
this.workgroupJID = workgroupJID;
|
||||
}
|
||||
|
@ -56,7 +57,7 @@ public class Agent {
|
|||
*
|
||||
* @return - the agents JID.
|
||||
*/
|
||||
public String getUser() {
|
||||
public Jid getUser() {
|
||||
return connection.getUser();
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,9 @@ import org.jivesoftware.smack.filter.PacketFilter;
|
|||
import org.jivesoftware.smack.filter.PacketTypeFilter;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jxmpp.jid.FullJid;
|
||||
import org.jxmpp.jid.Jid;
|
||||
import org.jxmpp.jid.parts.Resourcepart;
|
||||
import org.jxmpp.util.XmppStringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -34,7 +37,6 @@ import java.util.HashMap;
|
|||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
|
@ -52,10 +54,10 @@ public class AgentRoster {
|
|||
private static final int EVENT_PRESENCE_CHANGED = 2;
|
||||
|
||||
private XMPPConnection connection;
|
||||
private String workgroupJID;
|
||||
private Jid workgroupJID;
|
||||
private List<String> entries;
|
||||
private List<AgentRosterListener> listeners;
|
||||
private Map<String, Map<String, Presence>> presenceMap;
|
||||
private final Map<Jid, Map<Resourcepart, Presence>> presenceMap = new HashMap<>();
|
||||
// The roster is marked as initialized when at least a single roster packet
|
||||
// has been recieved and processed.
|
||||
boolean rosterInitialized = false;
|
||||
|
@ -67,12 +69,11 @@ public class AgentRoster {
|
|||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
AgentRoster(XMPPConnection connection, String workgroupJID) throws NotConnectedException, InterruptedException {
|
||||
AgentRoster(XMPPConnection connection, Jid workgroupJID) throws NotConnectedException, InterruptedException {
|
||||
this.connection = connection;
|
||||
this.workgroupJID = workgroupJID;
|
||||
entries = new ArrayList<String>();
|
||||
listeners = new ArrayList<AgentRosterListener>();
|
||||
presenceMap = new HashMap<String, Map<String, Presence>>();
|
||||
// Listen for any roster packets.
|
||||
PacketFilter rosterFilter = new PacketTypeFilter(AgentStatusRequest.class);
|
||||
connection.addAsyncPacketListener(new AgentStatusListener(), rosterFilter);
|
||||
|
@ -118,7 +119,7 @@ public class AgentRoster {
|
|||
if (entries.contains(jid)) {
|
||||
// Fire the agent added event
|
||||
listener.agentAdded(jid);
|
||||
Map<String,Presence> userPresences = presenceMap.get(jid);
|
||||
Map<Resourcepart, Presence> userPresences = presenceMap.get(jid);
|
||||
if (userPresences != null) {
|
||||
Iterator<Presence> presences = userPresences.values().iterator();
|
||||
while (presences.hasNext()) {
|
||||
|
@ -176,14 +177,14 @@ public class AgentRoster {
|
|||
* or "user@domain/resource").
|
||||
* @return true if the XMPP address is an agent in the workgroup.
|
||||
*/
|
||||
public boolean contains(String jid) {
|
||||
public boolean contains(Jid jid) {
|
||||
if (jid == null) {
|
||||
return false;
|
||||
}
|
||||
synchronized (entries) {
|
||||
for (Iterator<String> i = entries.iterator(); i.hasNext();) {
|
||||
String entry = i.next();
|
||||
if (entry.toLowerCase(Locale.US).equals(jid.toLowerCase())) {
|
||||
if (entry.equals(jid)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -200,9 +201,9 @@ public class AgentRoster {
|
|||
* @return the agent's current presence, or <tt>null</tt> if the agent is unavailable
|
||||
* or if no presence information is available..
|
||||
*/
|
||||
public Presence getPresence(String user) {
|
||||
String key = getPresenceMapKey(user);
|
||||
Map<String, Presence> userPresences = presenceMap.get(key);
|
||||
public Presence getPresence(Jid user) {
|
||||
Jid key = getPresenceMapKey(user);
|
||||
Map<Resourcepart, Presence> userPresences = presenceMap.get(key);
|
||||
if (userPresences == null) {
|
||||
Presence presence = new Presence(Presence.Type.unavailable);
|
||||
presence.setFrom(user);
|
||||
|
@ -211,7 +212,7 @@ public class AgentRoster {
|
|||
else {
|
||||
// Find the resource with the highest priority
|
||||
// Might be changed to use the resource with the highest availability instead.
|
||||
Iterator<String> it = userPresences.keySet().iterator();
|
||||
Iterator<Resourcepart> it = userPresences.keySet().iterator();
|
||||
Presence p;
|
||||
Presence presence = null;
|
||||
|
||||
|
@ -248,10 +249,10 @@ public class AgentRoster {
|
|||
* @param user the fully qualified xmpp ID, e.g. jdoe@example.com/Work.
|
||||
* @return the key to use in the presenceMap for the fully qualified xmpp ID.
|
||||
*/
|
||||
private String getPresenceMapKey(String user) {
|
||||
String key = user;
|
||||
private Jid getPresenceMapKey(Jid user) {
|
||||
Jid key = user;
|
||||
if (!contains(user)) {
|
||||
key = XmppStringUtils.parseBareJid(user).toLowerCase(Locale.US);
|
||||
key = user.asBareJidIfPossible();
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
@ -286,13 +287,13 @@ public class AgentRoster {
|
|||
private class PresencePacketListener implements PacketListener {
|
||||
public void processPacket(Stanza packet) {
|
||||
Presence presence = (Presence)packet;
|
||||
String from = presence.getFrom();
|
||||
FullJid from = presence.getFrom().asFullJidIfPossible();
|
||||
if (from == null) {
|
||||
// TODO Check if we need to ignore these presences or this is a server bug?
|
||||
LOGGER.warning("Presence with no FROM: " + presence.toXML());
|
||||
LOGGER.warning("Presence with non full JID from: " + presence.toXML());
|
||||
return;
|
||||
}
|
||||
String key = getPresenceMapKey(from);
|
||||
Jid key = getPresenceMapKey(from);
|
||||
|
||||
// If an "available" packet, add it to the presence map. Each presence map will hold
|
||||
// for a particular user a map with the presence packets saved for each resource.
|
||||
|
@ -308,10 +309,10 @@ public class AgentRoster {
|
|||
else if (!workgroupJID.equals(agentStatus.getWorkgroupJID())) {
|
||||
return;
|
||||
}
|
||||
Map<String, Presence> userPresences;
|
||||
Map<Resourcepart, Presence> userPresences;
|
||||
// Get the user presence map
|
||||
if (presenceMap.get(key) == null) {
|
||||
userPresences = new HashMap<String, Presence>();
|
||||
userPresences = new HashMap<>();
|
||||
presenceMap.put(key, userPresences);
|
||||
}
|
||||
else {
|
||||
|
@ -319,13 +320,13 @@ public class AgentRoster {
|
|||
}
|
||||
// Add the new presence, using the resources as a key.
|
||||
synchronized (userPresences) {
|
||||
userPresences.put(XmppStringUtils.parseResource(from), presence);
|
||||
userPresences.put(from.getResourcepart(), presence);
|
||||
}
|
||||
// Fire an event.
|
||||
synchronized (entries) {
|
||||
for (Iterator<String> i = entries.iterator(); i.hasNext();) {
|
||||
String entry = i.next();
|
||||
if (entry.toLowerCase(Locale.US).equals(XmppStringUtils.parseBareJid(key).toLowerCase())) {
|
||||
if (entry.equals(key.asBareJidIfPossible())) {
|
||||
fireEvent(EVENT_PRESENCE_CHANGED, packet);
|
||||
}
|
||||
}
|
||||
|
@ -334,9 +335,9 @@ public class AgentRoster {
|
|||
// If an "unavailable" packet, remove any entries in the presence map.
|
||||
else if (presence.getType() == Presence.Type.unavailable) {
|
||||
if (presenceMap.get(key) != null) {
|
||||
Map<String,Presence> userPresences = presenceMap.get(key);
|
||||
Map<Resourcepart, Presence> userPresences = presenceMap.get(key);
|
||||
synchronized (userPresences) {
|
||||
userPresences.remove(XmppStringUtils.parseResource(from));
|
||||
userPresences.remove(from.getResourcepart());
|
||||
}
|
||||
if (userPresences.isEmpty()) {
|
||||
presenceMap.remove(key);
|
||||
|
@ -346,7 +347,7 @@ public class AgentRoster {
|
|||
synchronized (entries) {
|
||||
for (Iterator<String> i = entries.iterator(); i.hasNext();) {
|
||||
String entry = (String)i.next();
|
||||
if (entry.toLowerCase(Locale.US).equals(XmppStringUtils.parseBareJid(key).toLowerCase())) {
|
||||
if (entry.equals(key.asBareJidIfPossible())) {
|
||||
fireEvent(EVENT_PRESENCE_CHANGED, packet);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,8 @@ import org.jivesoftware.smackx.workgroup.packet.Transcripts;
|
|||
import org.jivesoftware.smackx.workgroup.settings.GenericSettings;
|
||||
import org.jivesoftware.smackx.workgroup.settings.SearchSettings;
|
||||
import org.jivesoftware.smackx.xdata.Form;
|
||||
import org.jxmpp.util.XmppStringUtils;
|
||||
import org.jxmpp.jid.Jid;
|
||||
import org.jxmpp.jid.parts.Resourcepart;
|
||||
|
||||
/**
|
||||
* This class embodies the agent's active presence within a given workgroup. The application
|
||||
|
@ -91,14 +92,14 @@ public class AgentSession {
|
|||
|
||||
private XMPPConnection connection;
|
||||
|
||||
private String workgroupJID;
|
||||
private Jid workgroupJID;
|
||||
|
||||
private boolean online = false;
|
||||
private Presence.Mode presenceMode;
|
||||
private int maxChats;
|
||||
private final Map<String, List<String>> metaData;
|
||||
|
||||
private Map<String, WorkgroupQueue> queues;
|
||||
private final Map<Resourcepart, WorkgroupQueue> queues = new HashMap<>();
|
||||
|
||||
private final List<OfferListener> offerListeners;
|
||||
private final List<WorkgroupInvitationListener> invitationListeners;
|
||||
|
@ -119,7 +120,7 @@ public class AgentSession {
|
|||
* authentication.
|
||||
* @param workgroupJID the fully qualified JID of the workgroup.
|
||||
*/
|
||||
public AgentSession(String workgroupJID, XMPPConnection connection) {
|
||||
public AgentSession(Jid 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.");
|
||||
|
@ -134,8 +135,6 @@ public class AgentSession {
|
|||
|
||||
this.metaData = new HashMap<String, List<String>>();
|
||||
|
||||
this.queues = new HashMap<String, WorkgroupQueue>();
|
||||
|
||||
offerListeners = new ArrayList<OfferListener>();
|
||||
invitationListeners = new ArrayList<WorkgroupInvitationListener>();
|
||||
queueUsersListeners = new ArrayList<QueueUsersListener>();
|
||||
|
@ -486,7 +485,7 @@ public class AgentSession {
|
|||
* @throws SmackException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public Transcripts getTranscripts(String userID) throws XMPPException, SmackException, InterruptedException {
|
||||
public Transcripts getTranscripts(Jid userID) throws XMPPException, SmackException, InterruptedException {
|
||||
return transcriptManager.getTranscripts(workgroupJID, userID);
|
||||
}
|
||||
|
||||
|
@ -514,7 +513,7 @@ public class AgentSession {
|
|||
* @throws InterruptedException
|
||||
*/
|
||||
public Form getTranscriptSearchForm() throws XMPPException, SmackException, InterruptedException {
|
||||
return transcriptSearchManager.getSearchForm(XmppStringUtils.parseDomain(workgroupJID));
|
||||
return transcriptSearchManager.getSearchForm(workgroupJID.asDomainBareJid());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -529,7 +528,7 @@ public class AgentSession {
|
|||
* @throws InterruptedException
|
||||
*/
|
||||
public ReportedData searchTranscripts(Form completedForm) throws XMPPException, SmackException, InterruptedException {
|
||||
return transcriptSearchManager.submitSearch(XmppStringUtils.parseDomain(workgroupJID),
|
||||
return transcriptSearchManager.submitSearch(workgroupJID.asDomainBareJid(),
|
||||
completedForm);
|
||||
}
|
||||
|
||||
|
@ -557,7 +556,7 @@ public class AgentSession {
|
|||
/**
|
||||
* @return the fully-qualified name of the workgroup for which this session exists
|
||||
*/
|
||||
public String getWorkgroupJID() {
|
||||
public Jid getWorkgroupJID() {
|
||||
return workgroupJID;
|
||||
}
|
||||
|
||||
|
@ -579,7 +578,7 @@ public class AgentSession {
|
|||
}
|
||||
|
||||
public Iterator<WorkgroupQueue> getQueues() {
|
||||
return Collections.unmodifiableMap((new HashMap<String, WorkgroupQueue>(queues))).values().iterator();
|
||||
return Collections.unmodifiableMap((new HashMap<>(queues))).values().iterator();
|
||||
}
|
||||
|
||||
public void addQueueUsersListener(QueueUsersListener listener) {
|
||||
|
@ -668,8 +667,8 @@ public class AgentSession {
|
|||
}
|
||||
}
|
||||
|
||||
private void fireInvitationEvent(String groupChatJID, String sessionID, String body,
|
||||
String from, Map<String, List<String>> metaData) {
|
||||
private void fireInvitationEvent(Jid groupChatJID, String sessionID, String body,
|
||||
Jid from, Map<String, List<String>> metaData) {
|
||||
WorkgroupInvitation invitation = new WorkgroupInvitation(connection.getUser(), groupChatJID,
|
||||
workgroupJID, sessionID, body, from, metaData);
|
||||
|
||||
|
@ -717,7 +716,7 @@ public class AgentSession {
|
|||
// check for different packet extensions to see what type of presence
|
||||
// packet it is.
|
||||
|
||||
String queueName = XmppStringUtils.parseResource(presence.getFrom());
|
||||
Resourcepart queueName = presence.getFrom().getResourceOrNull();
|
||||
WorkgroupQueue queue = queues.get(queueName);
|
||||
// If there isn't already an entry for the queue, create a new one.
|
||||
if (queue == null) {
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
|
|||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
@ -40,9 +41,9 @@ public class Offer {
|
|||
private AgentSession session;
|
||||
|
||||
private String sessionID;
|
||||
private String userJID;
|
||||
private String userID;
|
||||
private String workgroupName;
|
||||
private Jid userJID;
|
||||
private Jid userID;
|
||||
private Jid workgroupName;
|
||||
private Date expiresDate;
|
||||
private Map<String, List<String>> metaData;
|
||||
private OfferContent content;
|
||||
|
@ -63,8 +64,8 @@ public class Offer {
|
|||
* @param content content of the offer. The content explains the reason for the offer
|
||||
* (e.g. user request, transfer)
|
||||
*/
|
||||
Offer(XMPPConnection conn, AgentSession agentSession, String userID,
|
||||
String userJID, String workgroupName, Date expiresDate,
|
||||
Offer(XMPPConnection conn, AgentSession agentSession, Jid userID,
|
||||
Jid userJID, Jid workgroupName, Date expiresDate,
|
||||
String sessionID, Map<String, List<String>> metaData, OfferContent content)
|
||||
{
|
||||
this.connection = conn;
|
||||
|
@ -110,7 +111,7 @@ public class Offer {
|
|||
*
|
||||
* @return the userID of the user from which the offer originates.
|
||||
*/
|
||||
public String getUserID() {
|
||||
public Jid getUserID() {
|
||||
return userID;
|
||||
}
|
||||
|
||||
|
@ -119,7 +120,7 @@ public class Offer {
|
|||
*
|
||||
* @return the user's JID.
|
||||
*/
|
||||
public String getUserJID() {
|
||||
public Jid getUserJID() {
|
||||
return userJID;
|
||||
}
|
||||
|
||||
|
@ -128,7 +129,7 @@ public class Offer {
|
|||
*
|
||||
* @return the name of the workgroup.
|
||||
*/
|
||||
public String getWorkgroupName() {
|
||||
public Jid getWorkgroupName() {
|
||||
return this.workgroupName;
|
||||
}
|
||||
|
||||
|
@ -195,7 +196,7 @@ public class Offer {
|
|||
*/
|
||||
private class RejectPacket extends IQ {
|
||||
|
||||
RejectPacket(String workgroup) {
|
||||
RejectPacket(Jid workgroup) {
|
||||
super("offer-reject", "http://jabber.org/protocol/workgroup");
|
||||
this.setTo(workgroup);
|
||||
this.setType(IQ.Type.set);
|
||||
|
@ -214,7 +215,7 @@ public class Offer {
|
|||
*/
|
||||
private class AcceptPacket extends IQ {
|
||||
|
||||
AcceptPacket(String workgroup) {
|
||||
AcceptPacket(Jid workgroup) {
|
||||
super("offer-accept", "http://jabber.org/protocol/workgroup");
|
||||
this.setTo(workgroup);
|
||||
this.setType(IQ.Type.set);
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.jivesoftware.smack.XMPPConnection;
|
|||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.SimpleIQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jxmpp.jid.Jid;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
|
@ -53,7 +54,7 @@ public class OfferConfirmation extends SimpleIQ {
|
|||
}
|
||||
|
||||
|
||||
public void notifyService(XMPPConnection con, String workgroup, String createdRoomName) throws NotConnectedException, InterruptedException {
|
||||
public void notifyService(XMPPConnection con, Jid workgroup, String createdRoomName) throws NotConnectedException, InterruptedException {
|
||||
NotifyServicePacket packet = new NotifyServicePacket(workgroup, createdRoomName);
|
||||
con.sendPacket(packet);
|
||||
}
|
||||
|
@ -100,7 +101,7 @@ public class OfferConfirmation extends SimpleIQ {
|
|||
private class NotifyServicePacket extends IQ {
|
||||
String roomName;
|
||||
|
||||
NotifyServicePacket(String workgroup, String roomName) {
|
||||
NotifyServicePacket(Jid workgroup, String roomName) {
|
||||
super("offer-confirmation", "http://jabber.org/protocol/workgroup");
|
||||
this.setTo(workgroup);
|
||||
this.setType(IQ.Type.result);
|
||||
|
|
|
@ -19,6 +19,8 @@ package org.jivesoftware.smackx.workgroup.agent;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
/**
|
||||
* An immutable simple class to embody the information concerning a revoked offer, this is namely
|
||||
* the reason, the workgroup, the userJID, and the timestamp which the message was received.<br>
|
||||
|
@ -27,9 +29,9 @@ import java.util.Date;
|
|||
*/
|
||||
public class RevokedOffer {
|
||||
|
||||
private String userJID;
|
||||
private String userID;
|
||||
private String workgroupName;
|
||||
private Jid userJID;
|
||||
private Jid userID;
|
||||
private Jid workgroupName;
|
||||
private String sessionID;
|
||||
private String reason;
|
||||
private Date timestamp;
|
||||
|
@ -43,7 +45,7 @@ public class RevokedOffer {
|
|||
* @param reason the server issued message as to why this revocation was issued.
|
||||
* @param timestamp the timestamp at which the revocation was issued
|
||||
*/
|
||||
RevokedOffer(String userJID, String userID, String workgroupName, String sessionID,
|
||||
RevokedOffer(Jid userJID, Jid userID, Jid workgroupName, String sessionID,
|
||||
String reason, Date timestamp) {
|
||||
super();
|
||||
|
||||
|
@ -55,21 +57,21 @@ public class RevokedOffer {
|
|||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public String getUserJID() {
|
||||
public Jid getUserJID() {
|
||||
return userJID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the jid of the user for which this revocation was issued
|
||||
*/
|
||||
public String getUserID() {
|
||||
public Jid getUserID() {
|
||||
return this.userID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the fully qualified name of the workgroup
|
||||
*/
|
||||
public String getWorkgroupName() {
|
||||
public Jid getWorkgroupName() {
|
||||
return this.workgroupName;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,11 +23,12 @@ import org.jivesoftware.smack.SmackException.NoResponseException;
|
|||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
/**
|
||||
* A TranscriptManager helps to retrieve the full conversation transcript of a given session
|
||||
* {@link #getTranscript(String, String)} or to retrieve a list with the summary of all the
|
||||
* conversations that a user had {@link #getTranscripts(String, String)}.
|
||||
* {@link #getTranscript(Jid, String)} or to retrieve a list with the summary of all the
|
||||
* conversations that a user had {@link #getTranscripts(Jid, Jid)}.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
|
@ -49,7 +50,7 @@ public class TranscriptManager {
|
|||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public Transcript getTranscript(String workgroupJID, String sessionID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
public Transcript getTranscript(Jid workgroupJID, String sessionID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
Transcript request = new Transcript(sessionID);
|
||||
request.setTo(workgroupJID);
|
||||
Transcript response = (Transcript) connection.createPacketCollectorAndSend(request).nextResultOrThrow();
|
||||
|
@ -68,7 +69,7 @@ public class TranscriptManager {
|
|||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public Transcripts getTranscripts(String workgroupJID, String userID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
public Transcripts getTranscripts(Jid workgroupJID, Jid userID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
Transcripts request = new Transcripts(userID);
|
||||
request.setTo(workgroupJID);
|
||||
Transcripts response = (Transcripts) connection.createPacketCollectorAndSend(request).nextResultOrThrow();
|
||||
|
|
|
@ -25,11 +25,12 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
|
|||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jxmpp.jid.DomainBareJid;
|
||||
|
||||
/**
|
||||
* A TranscriptSearchManager helps to retrieve the form to use for searching transcripts
|
||||
* {@link #getSearchForm(String)} or to submit a search form and return the results of
|
||||
* the search {@link #submitSearch(String, Form)}.
|
||||
* {@link #getSearchForm(DomainBareJid)} or to submit a search form and return the results of
|
||||
* the search {@link #submitSearch(DomainBareJid, Form)}.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
|
@ -52,7 +53,7 @@ public class TranscriptSearchManager {
|
|||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public Form getSearchForm(String serviceJID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
public Form getSearchForm(DomainBareJid serviceJID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
TranscriptSearch search = new TranscriptSearch();
|
||||
search.setType(IQ.Type.get);
|
||||
search.setTo(serviceJID);
|
||||
|
@ -75,7 +76,7 @@ public class TranscriptSearchManager {
|
|||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public ReportedData submitSearch(String serviceJID, Form completedForm) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
public ReportedData submitSearch(DomainBareJid serviceJID, Form completedForm) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
TranscriptSearch search = new TranscriptSearch();
|
||||
search.setType(IQ.Type.get);
|
||||
search.setTo(serviceJID);
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.Locale;
|
|||
import java.util.Set;
|
||||
|
||||
import org.jivesoftware.smackx.workgroup.QueueUser;
|
||||
import org.jxmpp.jid.parts.Resourcepart;
|
||||
|
||||
/**
|
||||
* A queue in a workgroup, which is a pool of agents that are routed a specific type of
|
||||
|
@ -32,7 +33,7 @@ import org.jivesoftware.smackx.workgroup.QueueUser;
|
|||
*/
|
||||
public class WorkgroupQueue {
|
||||
|
||||
private String name;
|
||||
private Resourcepart name;
|
||||
private Status status = Status.CLOSED;
|
||||
|
||||
private int averageWaitTime = -1;
|
||||
|
@ -47,7 +48,7 @@ public class WorkgroupQueue {
|
|||
*
|
||||
* @param name the name of the queue.
|
||||
*/
|
||||
WorkgroupQueue(String name) {
|
||||
WorkgroupQueue(Resourcepart name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
@ -56,7 +57,7 @@ public class WorkgroupQueue {
|
|||
*
|
||||
* @return the name of the queue.
|
||||
*/
|
||||
public String getName() {
|
||||
public Resourcepart getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@ package org.jivesoftware.smackx.workgroup.packet;
|
|||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
import org.jxmpp.jid.Jid;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
|
@ -37,7 +39,7 @@ import java.util.List;
|
|||
*/
|
||||
public class AgentWorkgroups extends IQ {
|
||||
|
||||
private String agentJID;
|
||||
private Jid agentJID;
|
||||
private List<String> workgroups;
|
||||
|
||||
private AgentWorkgroups() {
|
||||
|
@ -50,7 +52,7 @@ public class AgentWorkgroups extends IQ {
|
|||
*
|
||||
* @param agentJID the id of the agent to get his workgroups.
|
||||
*/
|
||||
public AgentWorkgroups(String agentJID) {
|
||||
public AgentWorkgroups(Jid agentJID) {
|
||||
this();
|
||||
this.agentJID = agentJID;
|
||||
this.workgroups = new ArrayList<String>();
|
||||
|
@ -63,13 +65,13 @@ public class AgentWorkgroups extends IQ {
|
|||
* @param agentJID the id of the agent that can work in the list of workgroups.
|
||||
* @param workgroups the list of workgroup JIDs where the agent can work.
|
||||
*/
|
||||
public AgentWorkgroups(String agentJID, List<String> workgroups) {
|
||||
public AgentWorkgroups(Jid agentJID, List<String> workgroups) {
|
||||
this();
|
||||
this.agentJID = agentJID;
|
||||
this.workgroups = workgroups;
|
||||
}
|
||||
|
||||
public String getAgentJID() {
|
||||
public Jid getAgentJID() {
|
||||
return agentJID;
|
||||
}
|
||||
|
||||
|
@ -103,7 +105,7 @@ public class AgentWorkgroups extends IQ {
|
|||
|
||||
@Override
|
||||
public AgentWorkgroups parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
|
||||
String agentJID = parser.getAttributeValue("", "jid");
|
||||
final Jid agentJID = ParserUtils.getJidAttribute(parser);
|
||||
List<String> workgroups = new ArrayList<String>();
|
||||
|
||||
boolean done = false;
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package org.jivesoftware.smackx.workgroup.packet;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
/**
|
||||
* A IQ packet used to depart a workgroup queue. There are two cases for issuing a depart
|
||||
|
@ -32,7 +33,7 @@ import org.jivesoftware.smack.packet.IQ;
|
|||
*/
|
||||
public class DepartQueuePacket extends IQ {
|
||||
|
||||
private String user;
|
||||
private Jid user;
|
||||
|
||||
private DepartQueuePacket() {
|
||||
super("depart-queue", "http://jabber.org/protocol/workgroup");
|
||||
|
@ -43,7 +44,7 @@ public class DepartQueuePacket extends IQ {
|
|||
*
|
||||
* @param workgroup the workgroup to depart.
|
||||
*/
|
||||
public DepartQueuePacket(String workgroup) {
|
||||
public DepartQueuePacket(Jid workgroup) {
|
||||
this(workgroup, null);
|
||||
}
|
||||
|
||||
|
@ -54,7 +55,7 @@ public class DepartQueuePacket extends IQ {
|
|||
* @param workgroup the workgroup to depart.
|
||||
* @param user the user to make depart from the queue.
|
||||
*/
|
||||
public DepartQueuePacket(String workgroup, String user) {
|
||||
public DepartQueuePacket(Jid workgroup, Jid user) {
|
||||
this();
|
||||
this.user = user;
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@ import org.jivesoftware.smack.SmackException;
|
|||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
import org.jxmpp.jid.Jid;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
|
@ -59,9 +61,9 @@ public class OfferRequestProvider extends IQProvider<IQ> {
|
|||
// throw exception
|
||||
}
|
||||
|
||||
String userJID = parser.getAttributeValue("", "jid");
|
||||
Jid userJID = ParserUtils.getJidAttribute(parser);
|
||||
// Default userID to the JID.
|
||||
String userID = userJID;
|
||||
Jid userID = userJID;
|
||||
|
||||
while (!done) {
|
||||
eventType = parser.next();
|
||||
|
@ -79,7 +81,7 @@ public class OfferRequestProvider extends IQProvider<IQ> {
|
|||
sessionID = parser.getAttributeValue("", "id");
|
||||
}
|
||||
else if (UserID.ELEMENT_NAME.equals(elemName)) {
|
||||
userID = parser.getAttributeValue("", "id");
|
||||
userID = ParserUtils.getJidAttribute(parser, "id");
|
||||
}
|
||||
else if ("user-request".equals(elemName)) {
|
||||
content = UserRequest.getInstance();
|
||||
|
@ -113,13 +115,13 @@ public class OfferRequestProvider extends IQProvider<IQ> {
|
|||
public static class OfferRequestPacket extends IQ {
|
||||
|
||||
private int timeout;
|
||||
private String userID;
|
||||
private String userJID;
|
||||
private Jid userID;
|
||||
private Jid userJID;
|
||||
private Map<String, List<String>> metaData;
|
||||
private String sessionID;
|
||||
private OfferContent content;
|
||||
|
||||
public OfferRequestPacket(String userJID, String userID, int timeout, Map<String, List<String>> metaData,
|
||||
public OfferRequestPacket(Jid userJID, Jid userID, int timeout, Map<String, List<String>> metaData,
|
||||
String sessionID, OfferContent content)
|
||||
{
|
||||
super("offer", "http://jabber.org/protocol/workgroup");
|
||||
|
@ -137,7 +139,7 @@ public class OfferRequestProvider extends IQProvider<IQ> {
|
|||
*
|
||||
* @return the user ID.
|
||||
*/
|
||||
public String getUserID() {
|
||||
public Jid getUserID() {
|
||||
return userID;
|
||||
}
|
||||
|
||||
|
@ -146,7 +148,7 @@ public class OfferRequestProvider extends IQProvider<IQ> {
|
|||
*
|
||||
* @return the user JID.
|
||||
*/
|
||||
public String getUserJID() {
|
||||
public Jid getUserJID() {
|
||||
return userJID;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ import java.io.IOException;
|
|||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
import org.jxmpp.jid.Jid;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
|
@ -34,9 +36,9 @@ public class OfferRevokeProvider extends IQProvider<IQ> {
|
|||
@Override
|
||||
public OfferRevokePacket parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
|
||||
// The parser will be positioned on the opening IQ tag, so get the JID attribute.
|
||||
String userJID = parser.getAttributeValue("", "jid");
|
||||
Jid userJID = ParserUtils.getJidAttribute(parser);
|
||||
// Default the userID to the JID.
|
||||
String userID = userJID;
|
||||
Jid userID = userJID;
|
||||
String reason = null;
|
||||
String sessionID = null;
|
||||
boolean done = false;
|
||||
|
@ -53,7 +55,7 @@ public class OfferRevokeProvider extends IQProvider<IQ> {
|
|||
}
|
||||
else if ((eventType == XmlPullParser.START_TAG)
|
||||
&& parser.getName().equals(UserID.ELEMENT_NAME)) {
|
||||
userID = parser.getAttributeValue("", "id");
|
||||
userID = ParserUtils.getJidAttribute(parser, "id");
|
||||
}
|
||||
else if ((eventType == XmlPullParser.END_TAG) && parser.getName().equals(
|
||||
"offer-revoke"))
|
||||
|
@ -67,12 +69,12 @@ public class OfferRevokeProvider extends IQProvider<IQ> {
|
|||
|
||||
public class OfferRevokePacket extends IQ {
|
||||
|
||||
private String userJID;
|
||||
private String userID;
|
||||
private Jid userJID;
|
||||
private Jid userID;
|
||||
private String sessionID;
|
||||
private String reason;
|
||||
|
||||
public OfferRevokePacket (String userJID, String userID, String cause, String sessionID) {
|
||||
public OfferRevokePacket (Jid userJID, Jid userID, String cause, String sessionID) {
|
||||
super("offer-revoke", "http://jabber.org/protocol/workgroup");
|
||||
this.userJID = userJID;
|
||||
this.userID = userID;
|
||||
|
@ -80,11 +82,11 @@ public class OfferRevokeProvider extends IQProvider<IQ> {
|
|||
this.sessionID = sessionID;
|
||||
}
|
||||
|
||||
public String getUserJID() {
|
||||
public Jid getUserJID() {
|
||||
return userJID;
|
||||
}
|
||||
|
||||
public String getUserID() {
|
||||
public Jid getUserID() {
|
||||
return this.userID;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.List;
|
|||
import java.util.TimeZone;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
/**
|
||||
* Represents a list of conversation transcripts that a user had in all his history. Each
|
||||
|
@ -40,7 +41,7 @@ public class Transcripts extends IQ {
|
|||
UTC_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT+0"));
|
||||
}
|
||||
|
||||
private String userID;
|
||||
private Jid userID;
|
||||
private List<Transcripts.TranscriptSummary> summaries;
|
||||
|
||||
|
||||
|
@ -49,7 +50,7 @@ public class Transcripts extends IQ {
|
|||
*
|
||||
* @param userID the id of the user to get his conversations transcripts.
|
||||
*/
|
||||
public Transcripts(String userID) {
|
||||
public Transcripts(Jid userID) {
|
||||
this(userID, new ArrayList<Transcripts.TranscriptSummary>());
|
||||
}
|
||||
|
||||
|
@ -60,7 +61,7 @@ public class Transcripts extends IQ {
|
|||
* anonymous users.
|
||||
* @param summaries the list of TranscriptSummaries.
|
||||
*/
|
||||
public Transcripts(String userID, List<Transcripts.TranscriptSummary> summaries) {
|
||||
public Transcripts(Jid userID, List<Transcripts.TranscriptSummary> summaries) {
|
||||
super("transcripts", "http://jabber.org/protocol/workgroup");
|
||||
this.userID = userID;
|
||||
this.summaries = summaries;
|
||||
|
@ -74,7 +75,7 @@ public class Transcripts extends IQ {
|
|||
*
|
||||
* @return the id of the user that was involved in the conversations.
|
||||
*/
|
||||
public String getUserID() {
|
||||
public Jid getUserID() {
|
||||
return userID;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
package org.jivesoftware.smackx.workgroup.packet;
|
||||
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
import org.jxmpp.jid.Jid;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
|
@ -43,7 +45,7 @@ public class TranscriptsProvider extends IQProvider<Transcripts> {
|
|||
|
||||
@Override
|
||||
public Transcripts parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
|
||||
String userID = parser.getAttributeValue("", "userID");
|
||||
Jid userID = ParserUtils.getJidAttribute(parser, "userID");
|
||||
List<Transcripts.TranscriptSummary> summaries = new ArrayList<Transcripts.TranscriptSummary>();
|
||||
|
||||
boolean done = false;
|
||||
|
|
|
@ -21,6 +21,8 @@ import java.io.IOException;
|
|||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
import org.jxmpp.jid.Jid;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
|
@ -36,13 +38,13 @@ public class UserID implements PacketExtension {
|
|||
*/
|
||||
public static final String NAMESPACE = "http://jivesoftware.com/protocol/workgroup";
|
||||
|
||||
private String userID;
|
||||
private Jid userID;
|
||||
|
||||
public UserID(String userID) {
|
||||
public UserID(Jid userID) {
|
||||
this.userID = userID;
|
||||
}
|
||||
|
||||
public String getUserID() {
|
||||
public Jid getUserID() {
|
||||
return this.userID;
|
||||
}
|
||||
|
||||
|
@ -69,7 +71,7 @@ public class UserID implements PacketExtension {
|
|||
@Override
|
||||
public UserID parse(XmlPullParser parser, int initialDepth)
|
||||
throws XmlPullParserException, IOException {
|
||||
String userID = parser.getAttributeValue("", "id");
|
||||
Jid userID = ParserUtils.getJidAttribute(parser, "id");
|
||||
|
||||
// Advance to end of extension.
|
||||
parser.next();
|
||||
|
|
|
@ -58,7 +58,8 @@ import org.jivesoftware.smackx.workgroup.settings.WorkgroupProperties;
|
|||
import org.jivesoftware.smackx.xdata.Form;
|
||||
import org.jivesoftware.smackx.xdata.FormField;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
import org.jxmpp.util.XmppStringUtils;
|
||||
import org.jxmpp.jid.DomainBareJid;
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
/**
|
||||
* Provides workgroup services for users. Users can join the workgroup queue, depart the
|
||||
|
@ -73,7 +74,7 @@ import org.jxmpp.util.XmppStringUtils;
|
|||
*/
|
||||
public class Workgroup {
|
||||
|
||||
private String workgroupJID;
|
||||
private Jid workgroupJID;
|
||||
private XMPPConnection connection;
|
||||
private boolean inQueue;
|
||||
private CopyOnWriteArraySet<WorkgroupInvitationListener> invitationListeners;
|
||||
|
@ -92,7 +93,7 @@ public class Workgroup {
|
|||
* @param connection an XMPP connection which must have already undergone a
|
||||
* successful login.
|
||||
*/
|
||||
public Workgroup(String workgroupJID, XMPPConnection connection) {
|
||||
public Workgroup(Jid 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.");
|
||||
|
@ -154,7 +155,7 @@ public class Workgroup {
|
|||
*
|
||||
* @return the name of the workgroup.
|
||||
*/
|
||||
public String getWorkgroupJID() {
|
||||
public Jid getWorkgroupJID() {
|
||||
return workgroupJID;
|
||||
}
|
||||
|
||||
|
@ -242,7 +243,7 @@ public class Workgroup {
|
|||
* possible. For example, when the user is logged in anonymously using a web client.
|
||||
* In that case the user ID might be a randomly generated value put into a persistent
|
||||
* cookie or a username obtained via the session. A userID can be explicitly
|
||||
* passed in by using the {@link #joinQueue(Form, String)} method. When specified,
|
||||
* passed in by using the {@link #joinQueue(Form, Jid)} method. When specified,
|
||||
* that userID will be used instead of the user's JID to track conversations. The
|
||||
* server will ignore a manually specified userID if the user's connection to the server
|
||||
* is not anonymous.
|
||||
|
@ -280,7 +281,7 @@ public class Workgroup {
|
|||
* possible. For example, when the user is logged in anonymously using a web client.
|
||||
* In that case the user ID might be a randomly generated value put into a persistent
|
||||
* cookie or a username obtained via the session. A userID can be explicitly
|
||||
* passed in by using the {@link #joinQueue(Form, String)} method. When specified,
|
||||
* passed in by using the {@link #joinQueue(Form, Jid)} method. When specified,
|
||||
* that userID will be used instead of the user's JID to track conversations. The
|
||||
* server will ignore a manually specified userID if the user's connection to the server
|
||||
* is not anonymous.
|
||||
|
@ -332,7 +333,7 @@ public class Workgroup {
|
|||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public void joinQueue(Form answerForm, String userID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
public void joinQueue(Form answerForm, Jid userID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
// If already in the queue ignore the join request.
|
||||
if (inQueue) {
|
||||
throw new IllegalStateException("Already in queue " + workgroupJID);
|
||||
|
@ -380,7 +381,7 @@ public class Workgroup {
|
|||
* @throws SmackException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public void joinQueue(Map<String,Object> metadata, String userID) throws XMPPException, SmackException, InterruptedException {
|
||||
public void joinQueue(Map<String,Object> metadata, Jid userID) throws XMPPException, SmackException, InterruptedException {
|
||||
// If already in the queue ignore the join request.
|
||||
if (inQueue) {
|
||||
throw new IllegalStateException("Already in queue " + workgroupJID);
|
||||
|
@ -553,10 +554,10 @@ public class Workgroup {
|
|||
*/
|
||||
private class JoinQueuePacket extends IQ {
|
||||
|
||||
private String userID = null;
|
||||
private Jid userID;
|
||||
private DataForm form;
|
||||
|
||||
public JoinQueuePacket(String workgroup, Form answerForm, String userID) {
|
||||
public JoinQueuePacket(Jid workgroup, Form answerForm, Jid userID) {
|
||||
super("join-queue", "http://jabber.org/protocol/workgroup");
|
||||
this.userID = userID;
|
||||
|
||||
|
@ -660,7 +661,7 @@ public class Workgroup {
|
|||
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||
|
||||
try {
|
||||
String workgroupService = XmppStringUtils.parseDomain(workgroupJID);
|
||||
DomainBareJid workgroupService = workgroupJID.asDomainBareJid();
|
||||
DiscoverInfo infoResult = discoManager.discoverInfo(workgroupService);
|
||||
return infoResult.containsFeature("jive:email:provider");
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package org.jivesoftware.smackx.xevent;
|
||||
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -30,24 +31,24 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
|
|||
*/
|
||||
public class DefaultMessageEventRequestListener implements MessageEventRequestListener {
|
||||
|
||||
public void deliveredNotificationRequested(String from, String packetID,
|
||||
public void deliveredNotificationRequested(Jid from, String packetID,
|
||||
MessageEventManager messageEventManager) throws NotConnectedException, InterruptedException
|
||||
{
|
||||
// Send to the message's sender that the message has been delivered
|
||||
messageEventManager.sendDeliveredNotification(from, packetID);
|
||||
}
|
||||
|
||||
public void displayedNotificationRequested(String from, String packetID,
|
||||
public void displayedNotificationRequested(Jid from, String packetID,
|
||||
MessageEventManager messageEventManager)
|
||||
{
|
||||
}
|
||||
|
||||
public void composingNotificationRequested(String from, String packetID,
|
||||
public void composingNotificationRequested(Jid from, String packetID,
|
||||
MessageEventManager messageEventManager)
|
||||
{
|
||||
}
|
||||
|
||||
public void offlineNotificationRequested(String from, String packetID,
|
||||
public void offlineNotificationRequested(Jid from, String packetID,
|
||||
MessageEventManager messageEventManager)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.jivesoftware.smack.filter.PacketFilter;
|
|||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smackx.xevent.packet.MessageEvent;
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -166,7 +167,7 @@ public class MessageEventManager extends Manager {
|
|||
* Fires message event request listeners.
|
||||
*/
|
||||
private void fireMessageEventRequestListeners(
|
||||
String from,
|
||||
Jid from,
|
||||
String packetID,
|
||||
String methodName) {
|
||||
try {
|
||||
|
@ -186,7 +187,7 @@ public class MessageEventManager extends Manager {
|
|||
* Fires message event notification listeners.
|
||||
*/
|
||||
private void fireMessageEventNotificationListeners(
|
||||
String from,
|
||||
Jid from,
|
||||
String packetID,
|
||||
String methodName) {
|
||||
try {
|
||||
|
@ -210,7 +211,7 @@ public class MessageEventManager extends Manager {
|
|||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public void sendDeliveredNotification(String to, String packetID) throws NotConnectedException, InterruptedException {
|
||||
public void sendDeliveredNotification(Jid to, String packetID) throws NotConnectedException, InterruptedException {
|
||||
// Create the message to send
|
||||
Message msg = new Message(to);
|
||||
// Create a MessageEvent Package and add it to the message
|
||||
|
@ -230,7 +231,7 @@ public class MessageEventManager extends Manager {
|
|||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public void sendDisplayedNotification(String to, String packetID) throws NotConnectedException, InterruptedException {
|
||||
public void sendDisplayedNotification(Jid to, String packetID) throws NotConnectedException, InterruptedException {
|
||||
// Create the message to send
|
||||
Message msg = new Message(to);
|
||||
// Create a MessageEvent Package and add it to the message
|
||||
|
@ -250,7 +251,7 @@ public class MessageEventManager extends Manager {
|
|||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public void sendComposingNotification(String to, String packetID) throws NotConnectedException, InterruptedException {
|
||||
public void sendComposingNotification(Jid to, String packetID) throws NotConnectedException, InterruptedException {
|
||||
// Create the message to send
|
||||
Message msg = new Message(to);
|
||||
// Create a MessageEvent Package and add it to the message
|
||||
|
@ -270,7 +271,7 @@ public class MessageEventManager extends Manager {
|
|||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public void sendCancelledNotification(String to, String packetID) throws NotConnectedException, InterruptedException {
|
||||
public void sendCancelledNotification(Jid to, String packetID) throws NotConnectedException, InterruptedException {
|
||||
// Create the message to send
|
||||
Message msg = new Message(to);
|
||||
// Create a MessageEvent Package and add it to the message
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package org.jivesoftware.smackx.xevent;
|
||||
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -50,7 +51,7 @@ public interface MessageEventRequestListener {
|
|||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public void deliveredNotificationRequested(String from, String packetID,
|
||||
public void deliveredNotificationRequested(Jid from, String packetID,
|
||||
MessageEventManager messageEventManager) throws NotConnectedException, InterruptedException;
|
||||
|
||||
/**
|
||||
|
@ -60,7 +61,7 @@ public interface MessageEventRequestListener {
|
|||
* @param packetID the id of the message that was sent.
|
||||
* @param messageEventManager the messageEventManager that fired the listener.
|
||||
*/
|
||||
public void displayedNotificationRequested(String from, String packetID,
|
||||
public void displayedNotificationRequested(Jid from, String packetID,
|
||||
MessageEventManager messageEventManager);
|
||||
|
||||
/**
|
||||
|
@ -71,7 +72,7 @@ public interface MessageEventRequestListener {
|
|||
* @param packetID the id of the message that was sent.
|
||||
* @param messageEventManager the messageEventManager that fired the listener.
|
||||
*/
|
||||
public void composingNotificationRequested(String from, String packetID,
|
||||
public void composingNotificationRequested(Jid from, String packetID,
|
||||
MessageEventManager messageEventManager);
|
||||
|
||||
/**
|
||||
|
@ -81,7 +82,7 @@ public interface MessageEventRequestListener {
|
|||
* @param packetID the id of the message that was sent.
|
||||
* @param messageEventManager the messageEventManager that fired the listener.
|
||||
*/
|
||||
public void offlineNotificationRequested(String from, String packetID,
|
||||
public void offlineNotificationRequested(Jid from, String packetID,
|
||||
MessageEventManager messageEventManager);
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@ import java.util.Collections;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
/**
|
||||
* Represents a roster item, which consists of a JID and , their name and
|
||||
* the groups the roster item belongs to. This roster item does not belong
|
||||
|
@ -34,7 +36,7 @@ import java.util.List;
|
|||
*/
|
||||
public class RemoteRosterEntry {
|
||||
|
||||
private String user;
|
||||
private Jid user;
|
||||
private String name;
|
||||
private final List<String> groupNames = new ArrayList<String>();
|
||||
|
||||
|
@ -46,7 +48,7 @@ public class RemoteRosterEntry {
|
|||
* @param groups the list of group names the entry will belong to, or <tt>null</tt> if the
|
||||
* the roster entry won't belong to a group.
|
||||
*/
|
||||
public RemoteRosterEntry(String user, String name, String [] groups) {
|
||||
public RemoteRosterEntry(Jid user, String name, String [] groups) {
|
||||
this.user = user;
|
||||
this.name = name;
|
||||
if (groups != null) {
|
||||
|
@ -59,7 +61,7 @@ public class RemoteRosterEntry {
|
|||
*
|
||||
* @return the user.
|
||||
*/
|
||||
public String getUser() {
|
||||
public Jid getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@ package org.jivesoftware.smackx.xroster;
|
|||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
/**
|
||||
*
|
||||
* A listener that is fired anytime a roster exchange is received.
|
||||
|
@ -34,6 +36,6 @@ public interface RosterExchangeListener {
|
|||
* @param remoteRosterEntries the entries sent by the user. The entries are instances of
|
||||
* RemoteRosterEntry.
|
||||
*/
|
||||
public void entriesReceived(String from, Iterator<RemoteRosterEntry> remoteRosterEntries);
|
||||
public void entriesReceived(Jid from, Iterator<RemoteRosterEntry> remoteRosterEntries);
|
||||
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.jivesoftware.smack.roster.Roster;
|
|||
import org.jivesoftware.smack.roster.RosterEntry;
|
||||
import org.jivesoftware.smack.roster.RosterGroup;
|
||||
import org.jivesoftware.smackx.xroster.packet.RosterExchange;
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -117,7 +118,7 @@ public class RosterExchangeManager {
|
|||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public void send(Roster roster, String targetUserID) throws NotConnectedException, InterruptedException {
|
||||
public void send(Roster roster, Jid targetUserID) throws NotConnectedException, InterruptedException {
|
||||
// Create a new message to send the roster
|
||||
Message msg = new Message(targetUserID);
|
||||
// Create a RosterExchange Package and add it to the message
|
||||
|
@ -137,7 +138,7 @@ public class RosterExchangeManager {
|
|||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public void send(RosterEntry rosterEntry, String targetUserID) throws NotConnectedException, InterruptedException {
|
||||
public void send(RosterEntry rosterEntry, Jid targetUserID) throws NotConnectedException, InterruptedException {
|
||||
// Create a new message to send the roster
|
||||
Message msg = new Message(targetUserID);
|
||||
// Create a RosterExchange Package and add it to the message
|
||||
|
@ -159,7 +160,7 @@ public class RosterExchangeManager {
|
|||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public void send(RosterGroup rosterGroup, String targetUserID) throws NotConnectedException, InterruptedException {
|
||||
public void send(RosterGroup rosterGroup, Jid targetUserID) throws NotConnectedException, InterruptedException {
|
||||
// Create a new message to send the roster
|
||||
Message msg = new Message(targetUserID);
|
||||
// Create a RosterExchange Package and add it to the message
|
||||
|
@ -177,7 +178,7 @@ public class RosterExchangeManager {
|
|||
/**
|
||||
* Fires roster exchange listeners.
|
||||
*/
|
||||
private void fireRosterExchangeListeners(String from, Iterator<RemoteRosterEntry> remoteRosterEntries) {
|
||||
private void fireRosterExchangeListeners(Jid from, Iterator<RemoteRosterEntry> remoteRosterEntries) {
|
||||
RosterExchangeListener[] listeners = null;
|
||||
synchronized (rosterExchangeListeners) {
|
||||
listeners = new RosterExchangeListener[rosterExchangeListeners.size()];
|
||||
|
|
|
@ -21,8 +21,10 @@ import java.io.IOException;
|
|||
import java.util.ArrayList;
|
||||
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
import org.jivesoftware.smackx.xroster.RemoteRosterEntry;
|
||||
import org.jivesoftware.smackx.xroster.packet.RosterExchange;
|
||||
import org.jxmpp.jid.Jid;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
|
@ -49,7 +51,7 @@ public class RosterExchangeProvider extends PacketExtensionProvider<RosterExchan
|
|||
RosterExchange rosterExchange = new RosterExchange();
|
||||
boolean done = false;
|
||||
RemoteRosterEntry remoteRosterEntry = null;
|
||||
String jid = "";
|
||||
Jid jid = null;
|
||||
String name = "";
|
||||
ArrayList<String> groupsName = new ArrayList<String>();
|
||||
while (!done) {
|
||||
|
@ -59,7 +61,7 @@ public class RosterExchangeProvider extends PacketExtensionProvider<RosterExchan
|
|||
// Reset this variable since they are optional for each item
|
||||
groupsName = new ArrayList<String>();
|
||||
// Initialize the variables from the parsed XML
|
||||
jid = parser.getAttributeValue("", "jid");
|
||||
jid = ParserUtils.getJidAttribute(parser);
|
||||
name = parser.getAttributeValue("", "name");
|
||||
}
|
||||
if (parser.getName().equals("group")) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue