diff --git a/source/org/jivesoftware/smackx/workgroup/agent/Agent.java b/source/org/jivesoftware/smackx/workgroup/agent/Agent.java
index 39beb3e75..a8aa6cf40 100644
--- a/source/org/jivesoftware/smackx/workgroup/agent/Agent.java
+++ b/source/org/jivesoftware/smackx/workgroup/agent/Agent.java
@@ -1,60 +1,119 @@
+/**
+* $RCSfile$
+* $Revision$
+* $Date$
+*
+* Copyright (C) 2002-2004 Jive Software. All rights reserved.
+* ====================================================================
+* The Jive Software License (based on Apache Software License, Version 1.1)
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+*
+* 1. Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided with the
+* distribution.
+*
+* 3. The end-user documentation included with the redistribution,
+* if any, must include the following acknowledgment:
+* "This product includes software developed by
+* Jive Software (http://www.jivesoftware.com)."
+* Alternately, this acknowledgment may appear in the software itself,
+* if and wherever such third-party acknowledgments normally appear.
+*
+* 4. The names "Smack" and "Jive Software" must not be used to
+* endorse or promote products derived from this software without
+* prior written permission. For written permission, please
+* contact webmaster@jivesoftware.com.
+*
+* 5. Products derived from this software may not be called "Smack",
+* nor may "Smack" appear in their name, without prior written
+* permission of Jive Software.
+*
+* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL JIVE SOFTWARE OR
+* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+* SUCH DAMAGE.
+* ====================================================================
+*/
+
package org.jivesoftware.smackx.workgroup.agent;
import org.jivesoftware.smack.packet.Presence;
/**
- * An Agent represents the agent role in a Workgroup Queue.
+ * An agent represents the agent role in a workgroup queue.
+ *
+ * @author Matt Tucker
*/
public class Agent {
- private String user;
- private int maxChats = -1;
- private int currentChats = -1;
- private Presence presence = null;
+ private String user;
+ private int maxChats = -1;
+ private int currentChats = -1;
+ private Presence presence = null;
/**
- * Creates an Agent
- * @param user - the current agents JID
- * @param currentChats - the number of chats the agent is in.
- * @param maxChats - the maximum number of chats the agent is allowed.
- * @param presence - the agents presence
+ * Creates an Agent.
+ *
+ * @param user the agent's JID.
+ * @param currentChats the number of chats the agent is currently in.
+ * @param maxChats the maximum number of chats the agent is allowed in.
+ * @param presence the agent's presence.
*/
- public Agent( String user, int currentChats, int maxChats, Presence presence ) {
- this.user = user;
- this.currentChats = currentChats;
- this.maxChats = maxChats;
- this.presence = presence;
- }
+ public Agent(String user, int currentChats, int maxChats, Presence presence) {
+ this.user = user;
+ this.currentChats = currentChats;
+ this.maxChats = maxChats;
+ this.presence = presence;
+ }
- /**
- * Return the agents JID
- * @return - the agents JID.
+ /**
+ * Return this agent's JID.
+ *
+ * @return this agent's JID.
*/
- public String getUser() {
- return user;
- }
+ public String getUser() {
+ return user;
+ }
- /**
- * Return the maximum number of chats for this agent.
- * @return - maximum number of chats allowed.
- */
- public int getMaxChats() {
- return maxChats;
- }
+ /**
+ * Return the maximum number of chats this agent can participate in.
+ *
+ * @return the maximum number of chats this agent can participate in.
+ */
+ public int getMaxChats() {
+ return maxChats;
+ }
- /**
- * Return the current chat count.
- * @return - the current chat count.
- */
- public int getCurrentChats() {
- return currentChats;
- }
+ /**
+ * Return the number of chats this agent is currently in.
+ *
+ * @return the number of chats this agent is currently in.
+ */
+ public int getCurrentChats() {
+ return currentChats;
+ }
- /**
- * Return the agents Presence
- * @return - the agents presence.
- */
- public Presence getPresence() {
- return presence;
- }
+ /**
+ * Return this agent's presence.
+ *
+ * @return this agent's presence.
+ */
+ public Presence getPresence() {
+ return presence;
+ }
}
diff --git a/source/org/jivesoftware/smackx/workgroup/agent/Offer.java b/source/org/jivesoftware/smackx/workgroup/agent/Offer.java
index d0c220579..46655464a 100644
--- a/source/org/jivesoftware/smackx/workgroup/agent/Offer.java
+++ b/source/org/jivesoftware/smackx/workgroup/agent/Offer.java
@@ -1,13 +1,54 @@
/**
- * $RCSfile$
- * $Revision$
- * $Date$
- *
- * Copyright (C) 1999-2003 Jive Software. All rights reserved.
- *
- * This software is the proprietary information of Jive Software.
- * Use is subject to license terms.
- */
+* $RCSfile$
+* $Revision$
+* $Date$
+*
+* Copyright (C) 2002-2004 Jive Software. All rights reserved.
+* ====================================================================
+* The Jive Software License (based on Apache Software License, Version 1.1)
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+*
+* 1. Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided with the
+* distribution.
+*
+* 3. The end-user documentation included with the redistribution,
+* if any, must include the following acknowledgment:
+* "This product includes software developed by
+* Jive Software (http://www.jivesoftware.com)."
+* Alternately, this acknowledgment may appear in the software itself,
+* if and wherever such third-party acknowledgments normally appear.
+*
+* 4. The names "Smack" and "Jive Software" must not be used to
+* endorse or promote products derived from this software without
+* prior written permission. For written permission, please
+* contact webmaster@jivesoftware.com.
+*
+* 5. Products derived from this software may not be called "Smack",
+* nor may "Smack" appear in their name, without prior written
+* permission of Jive Software.
+*
+* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL JIVE SOFTWARE OR
+* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+* SUCH DAMAGE.
+* ====================================================================
+*/
package org.jivesoftware.smackx.workgroup.agent;
@@ -19,145 +60,146 @@ import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Packet;
/**
- * A class embodying the semantic agent chat offer; specific instances allow the acceptance or
- * rejecting of the offer.
+ * A class embodying the semantic agent chat offer; specific instances allow
+ * the acceptance or rejecting of the offer.
*
* @author Matt Tucker
- * @author loki der quaeler
* @author Derek DeMoro
*/
public class Offer {
- private XMPPConnection connection;
- private AgentSession session;
- private String sessionID;
- private String userID;
- private String workgroupName;
- private Date expiresDate;
- private Map metaData;
+ private XMPPConnection connection;
+ private WorkgroupSession session;
- /**
- * Creates a new offer.
- *
- * @param conn the XMPP connection with which the issuing session was created.
- * @param agentSession the agent session instance through which this offer was issued.
- * @param userID the XMPP address of the user from which the offer originates.
- * @param workgroupName the fully qualified name of the workgroup.
- * @param expiresDate the date at which this offer expires.
- * @param sessionID the session id associated with the offer.
- * @param metaData the metadata associated with the offer.
- */
- public Offer( XMPPConnection conn, AgentSession agentSession, String userID,
+ private String sessionID;
+ private String userID;
+ private String workgroupName;
+ private Date expiresDate;
+ private Map metaData;
+
+ /**
+ * Creates a new offer.
+ *
+ * @param conn the XMPP connection with which the issuing session was created.
+ * @param workgroupSession the agent session instance through which this offer was issued.
+ * @param userID the XMPP address of the user from which the offer originates.
+ * @param workgroupName the fully qualified name of the workgroup.
+ * @param expiresDate the date at which this offer expires.
+ * @param sessionID the session id associated with the offer.
+ * @param metaData the metadata associated with the offer.
+ */
+ public Offer(XMPPConnection conn, WorkgroupSession workgroupSession, String userID,
String workgroupName, Date expiresDate,
- String sessionID, Map metaData ) {
- this.connection = conn;
- this.session = agentSession;
- this.userID = userID;
- this.workgroupName = workgroupName;
- this.expiresDate = expiresDate;
- this.sessionID = sessionID;
- this.metaData = metaData;
- }
-
- /**
- * Accepts the offer.
- */
- public void accept() {
- Packet acceptPacket = new AcceptPacket( this.session.getWorkgroupName() );
- connection.sendPacket( acceptPacket );
- // TODO: listen for a reply.
- }
-
- /**
- * Rejects the offer.
- */
- public void reject() {
- RejectPacket rejectPacket = new RejectPacket( this.session.getWorkgroupName() );
- connection.sendPacket( rejectPacket );
- // TODO: listen for a reply.
- }
-
- /**
- * Returns the XMPP address of the user from which the offer originates
- * (eg jsmith@example.com/WebClient). For example, if the user jsmith initiates
- * a support request by joining the workgroup queue, then this user ID will be
- * jsmith's address.
- *
- * @return the XMPP address of the user from which the offer originates.
- */
- public String getUserID() {
- return userID;
- }
-
- /**
- * The fully qualified name of the workgroup (eg support@example.com).
- *
- * @return the name of the workgroup.
- */
- public String getWorkgroupName() {
- return this.workgroupName;
- }
-
- /**
- * The date when the offer will expire. The agent must {@link #accept()}
- * the offer before the expiration date or the offer will lapse and be
- * routed to another agent. Alternatively, the agent can {@link #reject()}
- * the offer at any time if they don't wish to accept it..
- *
- * @return the date at which this offer expires.
- */
- public Date getExpiresDate() {
- return this.expiresDate;
- }
-
- /**
- * The session ID associated with the offer.
- *
- * @return the session id associated with the offer.
- */
- public String getSessionID() {
- return this.sessionID;
- }
-
- /**
- * The meta-data associated with the offer.
- *
- * @return the offer meta-data.
- */
- public Map getMetaData() {
- return this.metaData;
- }
-
- /**
- * Packet for rejecting offers.
- */
- private class RejectPacket extends IQ {
-
- RejectPacket( String workgroup ) {
- this.setTo( workgroup );
- this.setType( IQ.Type.SET );
+ String sessionID, Map metaData)
+ {
+ this.connection = conn;
+ this.session = workgroupSession;
+ this.userID = userID;
+ this.workgroupName = workgroupName;
+ this.expiresDate = expiresDate;
+ this.sessionID = sessionID;
+ this.metaData = metaData;
}
- public String getChildElementXML() {
- return "
+ * WorkgroupSession instance should implement.
*
* @author Matt Tucker
* @author loki der quaeler
- * @see org.jivesoftware.smackx.workgroup.agent.AgentSession
+ * @see org.jivesoftware.smackx.workgroup.agent.WorkgroupSession
*/
public interface OfferListener {
/**
- * The implementing class instance will be notified via this when the AgentSession has received
+ * The implementing class instance will be notified via this when the WorkgroupSession has received
* an offer for a chat. The instance will then have the ability to accept, reject, or ignore
* the request (resulting in a revocation-by-timeout).
*
diff --git a/source/org/jivesoftware/smackx/workgroup/agent/QueueAgentsListener.java b/source/org/jivesoftware/smackx/workgroup/agent/QueueAgentsListener.java
index a0ee4e14e..33ba9ef0c 100644
--- a/source/org/jivesoftware/smackx/workgroup/agent/QueueAgentsListener.java
+++ b/source/org/jivesoftware/smackx/workgroup/agent/QueueAgentsListener.java
@@ -1,3 +1,55 @@
+/**
+* $RCSfile$
+* $Revision$
+* $Date$
+*
+* Copyright (C) 2002-2004 Jive Software. All rights reserved.
+* ====================================================================
+* The Jive Software License (based on Apache Software License, Version 1.1)
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+*
+* 1. Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided with the
+* distribution.
+*
+* 3. The end-user documentation included with the redistribution,
+* if any, must include the following acknowledgment:
+* "This product includes software developed by
+* Jive Software (http://www.jivesoftware.com)."
+* Alternately, this acknowledgment may appear in the software itself,
+* if and wherever such third-party acknowledgments normally appear.
+*
+* 4. The names "Smack" and "Jive Software" must not be used to
+* endorse or promote products derived from this software without
+* prior written permission. For written permission, please
+* contact webmaster@jivesoftware.com.
+*
+* 5. Products derived from this software may not be called "Smack",
+* nor may "Smack" appear in their name, without prior written
+* permission of Jive Software.
+*
+* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL JIVE SOFTWARE OR
+* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+* SUCH DAMAGE.
+* ====================================================================
+*/
+
package org.jivesoftware.smackx.workgroup.agent;
import java.util.Set;
diff --git a/source/org/jivesoftware/smackx/workgroup/agent/QueueUsersListener.java b/source/org/jivesoftware/smackx/workgroup/agent/QueueUsersListener.java
index ce1a53fb7..97c41f3a5 100644
--- a/source/org/jivesoftware/smackx/workgroup/agent/QueueUsersListener.java
+++ b/source/org/jivesoftware/smackx/workgroup/agent/QueueUsersListener.java
@@ -1,3 +1,55 @@
+/**
+* $RCSfile$
+* $Revision$
+* $Date$
+*
+* Copyright (C) 2002-2004 Jive Software. All rights reserved.
+* ====================================================================
+* The Jive Software License (based on Apache Software License, Version 1.1)
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+*
+* 1. Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided with the
+* distribution.
+*
+* 3. The end-user documentation included with the redistribution,
+* if any, must include the following acknowledgment:
+* "This product includes software developed by
+* Jive Software (http://www.jivesoftware.com)."
+* Alternately, this acknowledgment may appear in the software itself,
+* if and wherever such third-party acknowledgments normally appear.
+*
+* 4. The names "Smack" and "Jive Software" must not be used to
+* endorse or promote products derived from this software without
+* prior written permission. For written permission, please
+* contact webmaster@jivesoftware.com.
+*
+* 5. Products derived from this software may not be called "Smack",
+* nor may "Smack" appear in their name, without prior written
+* permission of Jive Software.
+*
+* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL JIVE SOFTWARE OR
+* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+* SUCH DAMAGE.
+* ====================================================================
+*/
+
package org.jivesoftware.smackx.workgroup.agent;
import java.util.Date;
diff --git a/source/org/jivesoftware/smackx/workgroup/agent/RevokedOffer.java b/source/org/jivesoftware/smackx/workgroup/agent/RevokedOffer.java
index d6b6023fc..5896c4782 100644
--- a/source/org/jivesoftware/smackx/workgroup/agent/RevokedOffer.java
+++ b/source/org/jivesoftware/smackx/workgroup/agent/RevokedOffer.java
@@ -1,13 +1,54 @@
/**
- * $RCSfile$
- * $Revision$
- * $Date$
- *
- * Copyright (C) 1999-2003 Jive Software. All rights reserved.
- *
- * This software is the proprietary information of Jive Software.
- * Use is subject to license terms.
- */
+* $RCSfile$
+* $Revision$
+* $Date$
+*
+* Copyright (C) 2002-2004 Jive Software. All rights reserved.
+* ====================================================================
+* The Jive Software License (based on Apache Software License, Version 1.1)
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+*
+* 1. Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided with the
+* distribution.
+*
+* 3. The end-user documentation included with the redistribution,
+* if any, must include the following acknowledgment:
+* "This product includes software developed by
+* Jive Software (http://www.jivesoftware.com)."
+* Alternately, this acknowledgment may appear in the software itself,
+* if and wherever such third-party acknowledgments normally appear.
+*
+* 4. The names "Smack" and "Jive Software" must not be used to
+* endorse or promote products derived from this software without
+* prior written permission. For written permission, please
+* contact webmaster@jivesoftware.com.
+*
+* 5. Products derived from this software may not be called "Smack",
+* nor may "Smack" appear in their name, without prior written
+* permission of Jive Software.
+*
+* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL JIVE SOFTWARE OR
+* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+* SUCH DAMAGE.
+* ====================================================================
+*/
package org.jivesoftware.smackx.workgroup.agent;
diff --git a/source/org/jivesoftware/smackx/workgroup/agent/WorkgroupQueue.java b/source/org/jivesoftware/smackx/workgroup/agent/WorkgroupQueue.java
index ec068da14..eb9a191f6 100644
--- a/source/org/jivesoftware/smackx/workgroup/agent/WorkgroupQueue.java
+++ b/source/org/jivesoftware/smackx/workgroup/agent/WorkgroupQueue.java
@@ -1,13 +1,54 @@
/**
- * $RCSfile$
- * $Revision$
- * $Date$
- *
- * Copyright (C) 1999-2003 Jive Software. All rights reserved.
- *
- * This software is the proprietary information of Jive Software.
- * Use is subject to license terms.
- */
+* $RCSfile$
+* $Revision$
+* $Date$
+*
+* Copyright (C) 2002-2004 Jive Software. All rights reserved.
+* ====================================================================
+* The Jive Software License (based on Apache Software License, Version 1.1)
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+*
+* 1. Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+*
+* 2. Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in
+* the documentation and/or other materials provided with the
+* distribution.
+*
+* 3. The end-user documentation included with the redistribution,
+* if any, must include the following acknowledgment:
+* "This product includes software developed by
+* Jive Software (http://www.jivesoftware.com)."
+* Alternately, this acknowledgment may appear in the software itself,
+* if and wherever such third-party acknowledgments normally appear.
+*
+* 4. The names "Smack" and "Jive Software" must not be used to
+* endorse or promote products derived from this software without
+* prior written permission. For written permission, please
+* contact webmaster@jivesoftware.com.
+*
+* 5. Products derived from this software may not be called "Smack",
+* nor may "Smack" appear in their name, without prior written
+* permission of Jive Software.
+*
+* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL JIVE SOFTWARE OR
+* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+* SUCH DAMAGE.
+* ====================================================================
+*/
package org.jivesoftware.smackx.workgroup.agent;
@@ -174,11 +215,12 @@ public class WorkgroupQueue {
* A class to represent the status of the workgroup. The possible values are:
*
*
+ * + * The max chats value is the maximum number of chats the agent is willing to have routed to + * them at once. Some servers may be configured to only accept max chat values in a certain + * range; for example, between two and five. In that case, the maxChats value the agent sends + * may be adjusted by the server to a value within that range. + * + * @param presenceMode the presence mode of the agent. + * @param currentChats the current number of chats the agent is in. + * @param maxChats the maximum number of chats the agent is willing to accept. + * @throws XMPPException if an error occurs setting the agent status. + * @throws IllegalStateException if the agent is not online with the workgroup. + */ + public void setStatus(Presence.Mode presenceMode, int currentChats, int maxChats ) + throws XMPPException + { + setStatus( presenceMode, currentChats, maxChats, null ); + } + + + /** + * Sets the agent's current status with the workgroup. The presence mode affects how offers + * are routed to the agent. The possible presence modes with their meanings are as follows:
+ * + * The max chats value is the maximum number of chats the agent is willing to have routed to + * them at once. Some servers may be configured to only accept max chat values in a certain + * range; for example, between two and five. In that case, the maxChats value the agent sends + * may be adjusted by the server to a value within that range. + * + * @param presenceMode the presence mode of the agent. + * @param currentChats the current number of chats the agent is in. + * @param maxChats the maximum number of chats the agent is willing to accept. + * @param status sets the status message of the presence update. + * @throws XMPPException if an error occurs setting the agent status. + * @throws IllegalStateException if the agent is not online with the workgroup. + */ + public void setStatus(Presence.Mode presenceMode, int currentChats, int maxChats, String status ) + throws XMPPException + { + if (!online) { + throw new IllegalStateException("Cannot set status when the agent is not online."); + } + + if (presenceMode == null) { + presenceMode = Presence.Mode.AVAILABLE; + } + this.presenceMode = presenceMode; + this.currentChats = currentChats; + this.maxChats = maxChats; + + Presence presence = new Presence(Presence.Type.AVAILABLE); + presence.setMode(presenceMode); + presence.setTo(this.getWorkgroupName()); + + if( status != null ) { + presence.setStatus( status ); + } + // Send information about max chats and current chats as a packet extension. + DefaultPacketExtension agentStatus = new DefaultPacketExtension(AgentStatus.ELEMENT_NAME, + AgentStatus.NAMESPACE); + agentStatus.setValue("current-chats", ""+currentChats); + agentStatus.setValue("max-chats", ""+maxChats); + presence.addExtension(agentStatus); + presence.addExtension(new MetaData(this.metaData)); + + PacketCollector collector = this.connection.createPacketCollector(new AndFilter( + new PacketTypeFilter(Presence.class), new FromContainsFilter(workgroupName))); + + this.connection.sendPacket(presence); + + presence = (Presence)collector.nextResult(5000); + collector.cancel(); + if (presence == null) { + throw new XMPPException("No response from server on status set."); + } + + if (presence.getError() != null) { + throw new XMPPException(presence.getError()); + } + } + + /** + * Removes a user from the workgroup queue. This is an administrative action that the + * + * The agent is not guaranteed of having privileges to perform this action; an exception + * denying the request may be thrown. + */ + public void dequeueUser(String userID) throws XMPPException { + // todo: this method simply won't work right now. + DepartQueuePacket departPacket = new DepartQueuePacket(this.workgroupName); + + // PENDING + this.connection.sendPacket(departPacket); + } + + /** + * @return the fully-qualified name of the workgroup for which this session exists + */ + public String getWorkgroupName() { + return workgroupName; + } + + /** + * @param queueName the name of the queue + * @return an instance of WorkgroupQueue for the argument queue name, or null if none exists + */ + public WorkgroupQueue getQueue(String queueName) { + return (WorkgroupQueue)queues.get(queueName); + } + + public Iterator getQueues() { + return Collections.unmodifiableMap((new HashMap(queues))).values().iterator(); + } + + public void addQueueUsersListener(QueueUsersListener listener) { + synchronized(queueUsersListeners) { + if (!queueUsersListeners.contains(listener)) { + queueUsersListeners.add(listener); + } + } + } + + public void removeQueueUsersListener(QueueUsersListener listener) { + synchronized(queueUsersListeners) { + queueUsersListeners.remove(listener); + } + } + + public void addQueueAgentsListener(QueueAgentsListener listener) { + synchronized(queueAgentsListeners) { + if (!queueAgentsListeners.contains(listener)) { + queueAgentsListeners.add(listener); + } + } + } + + public void removeQueueAgentsListener(QueueAgentsListener listener) { + synchronized(queueAgentsListeners) { + queueAgentsListeners.remove(listener); + } + } + + /** + * Adds an offer listener. + * + * @param offerListener the offer listener. + */ + public void addOfferListener(OfferListener offerListener) { + synchronized(offerListeners) { + if (!offerListeners.contains(offerListener)) { + offerListeners.add(offerListener); + } + } + } + + /** + * Removes an offer listener. + * + * @param offerListener the offer listener. + */ + public void removeOfferListener(OfferListener offerListener) { + synchronized(offerListeners) { + offerListeners.remove(offerListener); + } + } + + /** + * Adds an invitation listener. + * + * @param invitationListener the invitation listener. + */ + public void addInvitationListener(InvitationListener invitationListener) { + synchronized(invitationListeners) { + if (!invitationListeners.contains(invitationListener)) { + invitationListeners.add(invitationListener); + } + } + } + + /** + * Removes an invitation listener. + * + * @param invitationListener the invitation listener. + */ + public void removeInvitationListener(InvitationListener invitationListener) { + synchronized(invitationListeners) { + offerListeners.remove(invitationListener); + } + } + + private void fireOfferRequestEvent(OfferRequestProvider.OfferRequestPacket requestPacket) { + Offer offer = new Offer(this.connection, this, requestPacket.getUserID(), + this.getWorkgroupName(), + new Date((new Date()).getTime() + + (requestPacket.getTimeout() * 1000)), + requestPacket.getSessionID(), requestPacket.getMetaData()); + + synchronized (offerListeners) { + for (Iterator i=offerListeners.iterator(); i.hasNext(); ) { + OfferListener listener = (OfferListener)i.next(); + listener.offerReceived(offer); + } + } + } + + private void fireOfferRevokeEvent(OfferRevokeProvider.OfferRevokePacket orp) { + RevokedOffer revokedOffer = new RevokedOffer(orp.getUserID(), this.getWorkgroupName(), + orp.getSessionID(), orp.getReason(), + new Date()); + + synchronized (offerListeners) { + for (Iterator i=offerListeners.iterator(); i.hasNext(); ) { + OfferListener listener = (OfferListener)i.next(); + listener.offerRevoked(revokedOffer); + } + } + } + + private void fireInvitationEvent(String groupChatJID, String sessionID, String body, + String from, Map metaData) + { + Invitation invitation = new Invitation(connection.getUser(), groupChatJID, + workgroupName, sessionID, body, from, metaData); + + synchronized(invitationListeners) { + for (Iterator i=invitationListeners.iterator(); i.hasNext(); ) { + InvitationListener listener = (InvitationListener)i.next(); + listener.invitationReceived(invitation); + } + } + } + + private void fireQueueUsersEvent(WorkgroupQueue queue, WorkgroupQueue.Status status, + int averageWaitTime, Date oldestEntry, Set users) + { + synchronized(queueUsersListeners) { + for (Iterator i=queueUsersListeners.iterator(); i.hasNext(); ) { + QueueUsersListener listener = (QueueUsersListener)i.next(); + if (status != null) { + listener.statusUpdated(queue, status); + } + if (averageWaitTime != -1) { + listener.averageWaitTimeUpdated(queue, averageWaitTime); + } + if (oldestEntry != null) { + listener.oldestEntryUpdated(queue, oldestEntry); + } + if (users != null) { + listener.usersUpdated(queue, users); + } + } + } + } + + private void fireQueueAgentsEvent(WorkgroupQueue queue, int currentChats, + int maxChats, Set agents) + { + synchronized(queueAgentsListeners) { + for (Iterator i=queueAgentsListeners.iterator(); i.hasNext(); ) { + QueueAgentsListener listener = (QueueAgentsListener)i.next(); + if (currentChats != -1) { + listener.currentChatsUpdated(queue, currentChats); + } + if (maxChats != -1) { + listener.maxChatsUpdated(queue, maxChats); + } + if (agents != null) { + listener.agentsUpdated(queue, agents); + } + } + } + } + + // PacketListener Implementation. + + private void handlePacket(Packet packet) { + if (packet instanceof OfferRequestProvider.OfferRequestPacket) { + fireOfferRequestEvent((OfferRequestProvider.OfferRequestPacket)packet); + } + else if (packet instanceof Presence) { + Presence presence = (Presence)packet; + + // The workgroup can send us a number of different presence packets. We + // check for different packet extensions to see what type of presence + // packet it is. + + String queueName = StringUtils.parseResource(presence.getFrom()); + WorkgroupQueue queue = (WorkgroupQueue)queues.get(queueName); + // If there isn't already an entry for the queue, create a new one. + if (queue == null) { + queue = new WorkgroupQueue(queueName); + queues.put(queueName, queue); + } + + // QueueOverview packet extensions contain basic information about a queue. + QueueOverview queueOverview = (QueueOverview)presence.getExtension( + QueueOverview.ELEMENT_NAME, QueueOverview.NAMESPACE); + if (queueOverview != null) { + if (queueOverview.getStatus() == null) { + queue.setStatus(WorkgroupQueue.Status.CLOSED); + } + else { + queue.setStatus(queueOverview.getStatus()); + } + queue.setAverageWaitTime(queueOverview.getAverageWaitTime()); + queue.setOldestEntry(queueOverview.getOldestEntry()); + // Fire event. + fireQueueUsersEvent(queue, queueOverview.getStatus(), + queueOverview.getAverageWaitTime(), queueOverview.getOldestEntry(), + null); + return; + } + + // QueueDetails packet extensions contain information about the users in + // a queue. + QueueDetails queueDetails = (QueueDetails)packet.getExtension( + QueueDetails.ELEMENT_NAME, QueueDetails.NAMESPACE); + if (queueDetails != null) { + queue.setUsers(queueDetails.getUsers()); + // Fire event. + fireQueueUsersEvent(queue, null, -1, null, queueDetails.getUsers()); + return; + } + + // Notify agent packets gives an overview of agent activity in a queue. + DefaultPacketExtension notifyAgents = (DefaultPacketExtension)presence.getExtension( + "notify-agents", "xmpp:workgroup"); + if (notifyAgents != null) { + int currentChats = Integer.parseInt(notifyAgents.getValue("current-chats")); + int maxChats = Integer.parseInt(notifyAgents.getValue("max-chats")); + queue.setCurrentChats(currentChats); + queue.setMaxChats(maxChats); + // Fire event. + fireQueueAgentsEvent(queue, currentChats, maxChats, null); + return; + } + + // Agent status + AgentStatus agentStatus = (AgentStatus)presence.getExtension(AgentStatus.ELEMENT_NAME, + AgentStatus.NAMESPACE); + if (agentStatus != null) { + Set agents = agentStatus.getAgents(); + // Look for information about the agent that created this session and + // update local status fields accordingly. + for (Iterator i=agents.iterator(); i.hasNext(); ) { + Agent agent = (Agent)i.next(); + if (agent.getUser().equals(StringUtils.parseBareAddress( + connection.getUser()))) + { + maxChats = agent.getMaxChats(); + currentChats = agent.getCurrentChats(); + } + } + // Set the list of agents for the queue. + queue.setAgents(agents); + // Fire event. + fireQueueAgentsEvent(queue, -1, -1, agentStatus.getAgents()); + return; + } + } + else if (packet instanceof Message) { + Message message = (Message)packet; + + GroupChatInvitation invitation = (GroupChatInvitation)message.getExtension( + GroupChatInvitation.ELEMENT_NAME, GroupChatInvitation.NAMESPACE); + + if (invitation != null) { + String roomAddress = invitation.getRoomAddress(); + String sessionID = null; + Map metaData = null; + + SessionID sessionIDExt = (SessionID)message.getExtension(SessionID.ELEMENT_NAME, + SessionID.NAMESPACE); + if (sessionIDExt != null) { + sessionID = sessionIDExt.getSessionID(); + } + + MetaData metaDataExt = (MetaData)message.getExtension(MetaData.ELEMENT_NAME, + MetaData.NAMESPACE); + if (metaDataExt != null) { + metaData = metaDataExt.getMetaData(); + } + + this.fireInvitationEvent(roomAddress, sessionID, message.getBody(), + message.getFrom(), metaData); + } + } + else if (packet instanceof OfferRevokeProvider.OfferRevokePacket) { + fireOfferRevokeEvent((OfferRevokeProvider.OfferRevokePacket)packet); + } + } +} \ No newline at end of file diff --git a/source/org/jivesoftware/smackx/workgroup/packet/AgentStatus.java b/source/org/jivesoftware/smackx/workgroup/packet/AgentStatus.java index 7bc606215..97e3033df 100644 --- a/source/org/jivesoftware/smackx/workgroup/packet/AgentStatus.java +++ b/source/org/jivesoftware/smackx/workgroup/packet/AgentStatus.java @@ -1,13 +1,55 @@ /** - * $RCSfile$ - * $Revision$ - * $Date$ - * - * Copyright (C) 1999-2003 Jive Software. All rights reserved. - * - * This software is the proprietary information of Jive Software. - * Use is subject to license terms. - */ +* $RCSfile$ +* $Revision$ +* $Date$ +* +* Copyright (C) 2002-2004 Jive Software. All rights reserved. +* ==================================================================== +* The Jive Software License (based on Apache Software License, Version 1.1) +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* +* 3. The end-user documentation included with the redistribution, +* if any, must include the following acknowledgment: +* "This product includes software developed by +* Jive Software (http://www.jivesoftware.com)." +* Alternately, this acknowledgment may appear in the software itself, +* if and wherever such third-party acknowledgments normally appear. +* +* 4. The names "Smack" and "Jive Software" must not be used to +* endorse or promote products derived from this software without +* prior written permission. For written permission, please +* contact webmaster@jivesoftware.com. +* +* 5. Products derived from this software may not be called "Smack", +* nor may "Smack" appear in their name, without prior written +* permission of Jive Software. +* +* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL JIVE SOFTWARE OR +* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +* SUCH DAMAGE. +* ==================================================================== +*/ + package org.jivesoftware.smackx.workgroup.packet; import java.util.*; @@ -19,7 +61,6 @@ import org.jivesoftware.smack.provider.ProviderManager; import org.xmlpull.v1.XmlPullParser; import org.jivesoftware.smackx.workgroup.agent.Agent; - /** * An immutable container around the basic data known about a given agent, as well as a * PacketExtension implementor which knows how to write the agent-status packet extension. diff --git a/source/org/jivesoftware/smackx/workgroup/packet/DepartQueuePacket.java b/source/org/jivesoftware/smackx/workgroup/packet/DepartQueuePacket.java index 17175e18a..c5ca24826 100644 --- a/source/org/jivesoftware/smackx/workgroup/packet/DepartQueuePacket.java +++ b/source/org/jivesoftware/smackx/workgroup/packet/DepartQueuePacket.java @@ -1,14 +1,54 @@ /** - * $RCSfile$ - * $Revision$ - * $Date$ - * - * Copyright (C) 1999-2003 Jive Software. All rights reserved. - * - * This software is the proprietary information of Jive Software. - * Use is subject to license terms. - */ - +* $RCSfile$ +* $Revision$ +* $Date$ +* +* Copyright (C) 2002-2004 Jive Software. All rights reserved. +* ==================================================================== +* The Jive Software License (based on Apache Software License, Version 1.1) +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* +* 3. The end-user documentation included with the redistribution, +* if any, must include the following acknowledgment: +* "This product includes software developed by +* Jive Software (http://www.jivesoftware.com)." +* Alternately, this acknowledgment may appear in the software itself, +* if and wherever such third-party acknowledgments normally appear. +* +* 4. The names "Smack" and "Jive Software" must not be used to +* endorse or promote products derived from this software without +* prior written permission. For written permission, please +* contact webmaster@jivesoftware.com. +* +* 5. Products derived from this software may not be called "Smack", +* nor may "Smack" appear in their name, without prior written +* permission of Jive Software. +* +* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL JIVE SOFTWARE OR +* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +* SUCH DAMAGE. +* ==================================================================== +*/ package org.jivesoftware.smackx.workgroup.packet; import org.jivesoftware.smack.packet.*; diff --git a/source/org/jivesoftware/smackx/workgroup/packet/MetaData.java b/source/org/jivesoftware/smackx/workgroup/packet/MetaData.java new file mode 100644 index 000000000..b5e3c86e5 --- /dev/null +++ b/source/org/jivesoftware/smackx/workgroup/packet/MetaData.java @@ -0,0 +1,59 @@ +/** + * $RCSfile$ + * $Revision$ + * $Date$ + * + * Copyright (C) 1999-2003 Jive Software. All rights reserved. + * + * This software is the proprietary information of Jive Software. + * Use is subject to license terms. + */ + +package org.jivesoftware.smackx.workgroup.packet; + +import java.util.Map; + +import org.jivesoftware.smackx.workgroup.util.MetaDataUtils; + +import org.jivesoftware.smack.packet.PacketExtension; + +/** + * MetaData packet extension. + */ +public class MetaData implements PacketExtension { + + /** + * Element name of the packet extension. + */ + public static final String ELEMENT_NAME = "metadata"; + + /** + * Namespace of the packet extension. + */ + public static final String NAMESPACE = "http://www.jivesoftware.com/workgroup/metadata"; + + private Map metaData; + + public MetaData(Map metaData) { + this.metaData = metaData; + } + + /** + * @return the Map of metadata contained by this instance + */ + public Map getMetaData() { + return metaData; + } + + public String getElementName() { + return ELEMENT_NAME; + } + + public String getNamespace() { + return NAMESPACE; + } + + public String toXML() { + return MetaDataUtils.encodeMetaData(this.getMetaData()); + } +} \ No newline at end of file diff --git a/source/org/jivesoftware/smackx/workgroup/packet/MetaDataProvider.java b/source/org/jivesoftware/smackx/workgroup/packet/MetaDataProvider.java index 5b1cc1c3d..47ecefcd9 100644 --- a/source/org/jivesoftware/smackx/workgroup/packet/MetaDataProvider.java +++ b/source/org/jivesoftware/smackx/workgroup/packet/MetaDataProvider.java @@ -1,19 +1,59 @@ /** - * $RCSfile$ - * $Revision$ - * $Date$ - * - * Copyright (C) 1999-2003 Jive Software. All rights reserved. - * - * This software is the proprietary information of Jive Software. - * Use is subject to license terms. - */ +* $RCSfile$ +* $Revision$ +* $Date$ +* +* Copyright (C) 2002-2004 Jive Software. All rights reserved. +* ==================================================================== +* The Jive Software License (based on Apache Software License, Version 1.1) +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* +* 3. The end-user documentation included with the redistribution, +* if any, must include the following acknowledgment: +* "This product includes software developed by +* Jive Software (http://www.jivesoftware.com)." +* Alternately, this acknowledgment may appear in the software itself, +* if and wherever such third-party acknowledgments normally appear. +* +* 4. The names "Smack" and "Jive Software" must not be used to +* endorse or promote products derived from this software without +* prior written permission. For written permission, please +* contact webmaster@jivesoftware.com. +* +* 5. Products derived from this software may not be called "Smack", +* nor may "Smack" appear in their name, without prior written +* permission of Jive Software. +* +* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL JIVE SOFTWARE OR +* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +* SUCH DAMAGE. +* ==================================================================== +*/ package org.jivesoftware.smackx.workgroup.packet; import java.util.Map; -import org.jivesoftware.smackx.workgroup.MetaData; import org.jivesoftware.smackx.workgroup.util.MetaDataUtils; import org.jivesoftware.smack.packet.PacketExtension; @@ -21,7 +61,6 @@ import org.jivesoftware.smack.provider.PacketExtensionProvider; import org.xmlpull.v1.XmlPullParser; - /** * This provider parses meta data if it's not contained already in a larger extension provider. * diff --git a/source/org/jivesoftware/smackx/workgroup/packet/OfferRequestProvider.java b/source/org/jivesoftware/smackx/workgroup/packet/OfferRequestProvider.java index 30627dff4..8239a4f16 100644 --- a/source/org/jivesoftware/smackx/workgroup/packet/OfferRequestProvider.java +++ b/source/org/jivesoftware/smackx/workgroup/packet/OfferRequestProvider.java @@ -1,13 +1,54 @@ /** - * $RCSfile$ - * $Revision$ - * $Date$ - * - * Copyright (C) 1999-2003 Jive Software. All rights reserved. - * - * This software is the proprietary information of Jive Software. - * Use is subject to license terms. - */ +* $RCSfile$ +* $Revision$ +* $Date$ +* +* Copyright (C) 2002-2004 Jive Software. All rights reserved. +* ==================================================================== +* The Jive Software License (based on Apache Software License, Version 1.1) +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* +* 3. The end-user documentation included with the redistribution, +* if any, must include the following acknowledgment: +* "This product includes software developed by +* Jive Software (http://www.jivesoftware.com)." +* Alternately, this acknowledgment may appear in the software itself, +* if and wherever such third-party acknowledgments normally appear. +* +* 4. The names "Smack" and "Jive Software" must not be used to +* endorse or promote products derived from this software without +* prior written permission. For written permission, please +* contact webmaster@jivesoftware.com. +* +* 5. Products derived from this software may not be called "Smack", +* nor may "Smack" appear in their name, without prior written +* permission of Jive Software. +* +* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL JIVE SOFTWARE OR +* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +* SUCH DAMAGE. +* ==================================================================== +*/ package org.jivesoftware.smackx.workgroup.packet; @@ -143,7 +184,7 @@ public class OfferRequestProvider implements IQProvider { } if (metaData != null) { - buf.append(MetaDataUtils.serializeMetaData(metaData)); + buf.append(MetaDataUtils.encodeMetaData(metaData)); } buf.append(""); diff --git a/source/org/jivesoftware/smackx/workgroup/packet/OfferRevokeProvider.java b/source/org/jivesoftware/smackx/workgroup/packet/OfferRevokeProvider.java index 6a09e305f..99ec89138 100644 --- a/source/org/jivesoftware/smackx/workgroup/packet/OfferRevokeProvider.java +++ b/source/org/jivesoftware/smackx/workgroup/packet/OfferRevokeProvider.java @@ -1,13 +1,54 @@ /** - * $RCSfile$ - * $Revision$ - * $Date$ - * - * Copyright (C) 1999-2003 Jive Software. All rights reserved. - * - * This software is the proprietary information of Jive Software. - * Use is subject to license terms. - */ +* $RCSfile$ +* $Revision$ +* $Date$ +* +* Copyright (C) 2002-2004 Jive Software. All rights reserved. +* ==================================================================== +* The Jive Software License (based on Apache Software License, Version 1.1) +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* +* 3. The end-user documentation included with the redistribution, +* if any, must include the following acknowledgment: +* "This product includes software developed by +* Jive Software (http://www.jivesoftware.com)." +* Alternately, this acknowledgment may appear in the software itself, +* if and wherever such third-party acknowledgments normally appear. +* +* 4. The names "Smack" and "Jive Software" must not be used to +* endorse or promote products derived from this software without +* prior written permission. For written permission, please +* contact webmaster@jivesoftware.com. +* +* 5. Products derived from this software may not be called "Smack", +* nor may "Smack" appear in their name, without prior written +* permission of Jive Software. +* +* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL JIVE SOFTWARE OR +* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +* SUCH DAMAGE. +* ==================================================================== +*/ package org.jivesoftware.smackx.workgroup.packet; diff --git a/source/org/jivesoftware/smackx/workgroup/packet/QueueDetails.java b/source/org/jivesoftware/smackx/workgroup/packet/QueueDetails.java index 7571f7269..f01e5f0ef 100644 --- a/source/org/jivesoftware/smackx/workgroup/packet/QueueDetails.java +++ b/source/org/jivesoftware/smackx/workgroup/packet/QueueDetails.java @@ -1,3 +1,55 @@ +/** +* $RCSfile$ +* $Revision$ +* $Date$ +* +* Copyright (C) 2002-2004 Jive Software. All rights reserved. +* ==================================================================== +* The Jive Software License (based on Apache Software License, Version 1.1) +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* +* 3. The end-user documentation included with the redistribution, +* if any, must include the following acknowledgment: +* "This product includes software developed by +* Jive Software (http://www.jivesoftware.com)." +* Alternately, this acknowledgment may appear in the software itself, +* if and wherever such third-party acknowledgments normally appear. +* +* 4. The names "Smack" and "Jive Software" must not be used to +* endorse or promote products derived from this software without +* prior written permission. For written permission, please +* contact webmaster@jivesoftware.com. +* +* 5. Products derived from this software may not be called "Smack", +* nor may "Smack" appear in their name, without prior written +* permission of Jive Software. +* +* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL JIVE SOFTWARE OR +* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +* SUCH DAMAGE. +* ==================================================================== +*/ + package org.jivesoftware.smackx.workgroup.packet; import org.jivesoftware.smack.packet.PacketExtension; @@ -7,8 +59,6 @@ import org.xmlpull.v1.XmlPullParser; import java.util.*; import java.text.SimpleDateFormat; -import org.jivesoftware.smackx.workgroup.QueueUser; - /** * Queue details packet extension, which contains details about the users * currently in a queue. diff --git a/source/org/jivesoftware/smackx/workgroup/packet/QueueOverview.java b/source/org/jivesoftware/smackx/workgroup/packet/QueueOverview.java index 83836f02f..e55600a6e 100644 --- a/source/org/jivesoftware/smackx/workgroup/packet/QueueOverview.java +++ b/source/org/jivesoftware/smackx/workgroup/packet/QueueOverview.java @@ -1,3 +1,55 @@ +/** +* $RCSfile$ +* $Revision$ +* $Date$ +* +* Copyright (C) 2002-2004 Jive Software. All rights reserved. +* ==================================================================== +* The Jive Software License (based on Apache Software License, Version 1.1) +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* +* 3. The end-user documentation included with the redistribution, +* if any, must include the following acknowledgment: +* "This product includes software developed by +* Jive Software (http://www.jivesoftware.com)." +* Alternately, this acknowledgment may appear in the software itself, +* if and wherever such third-party acknowledgments normally appear. +* +* 4. The names "Smack" and "Jive Software" must not be used to +* endorse or promote products derived from this software without +* prior written permission. For written permission, please +* contact webmaster@jivesoftware.com. +* +* 5. Products derived from this software may not be called "Smack", +* nor may "Smack" appear in their name, without prior written +* permission of Jive Software. +* +* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL JIVE SOFTWARE OR +* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +* SUCH DAMAGE. +* ==================================================================== +*/ + package org.jivesoftware.smackx.workgroup.packet; import org.jivesoftware.smack.packet.PacketExtension; diff --git a/source/org/jivesoftware/smackx/workgroup/packet/QueueUpdate.java b/source/org/jivesoftware/smackx/workgroup/packet/QueueUpdate.java index f4da2c927..e43b87d28 100644 --- a/source/org/jivesoftware/smackx/workgroup/packet/QueueUpdate.java +++ b/source/org/jivesoftware/smackx/workgroup/packet/QueueUpdate.java @@ -1,3 +1,55 @@ +/** +* $RCSfile$ +* $Revision$ +* $Date$ +* +* Copyright (C) 2002-2004 Jive Software. All rights reserved. +* ==================================================================== +* The Jive Software License (based on Apache Software License, Version 1.1) +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* +* 3. The end-user documentation included with the redistribution, +* if any, must include the following acknowledgment: +* "This product includes software developed by +* Jive Software (http://www.jivesoftware.com)." +* Alternately, this acknowledgment may appear in the software itself, +* if and wherever such third-party acknowledgments normally appear. +* +* 4. The names "Smack" and "Jive Software" must not be used to +* endorse or promote products derived from this software without +* prior written permission. For written permission, please +* contact webmaster@jivesoftware.com. +* +* 5. Products derived from this software may not be called "Smack", +* nor may "Smack" appear in their name, without prior written +* permission of Jive Software. +* +* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL JIVE SOFTWARE OR +* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +* SUCH DAMAGE. +* ==================================================================== +*/ + package org.jivesoftware.smackx.workgroup.packet; import org.jivesoftware.smack.packet.IQ; diff --git a/source/org/jivesoftware/smackx/workgroup/packet/QueueUser.java b/source/org/jivesoftware/smackx/workgroup/packet/QueueUser.java new file mode 100644 index 000000000..7b16b7658 --- /dev/null +++ b/source/org/jivesoftware/smackx/workgroup/packet/QueueUser.java @@ -0,0 +1,118 @@ +/** +* $RCSfile$ +* $Revision$ +* $Date$ +* +* Copyright (C) 2002-2004 Jive Software. All rights reserved. +* ==================================================================== +* The Jive Software License (based on Apache Software License, Version 1.1) +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* +* 3. The end-user documentation included with the redistribution, +* if any, must include the following acknowledgment: +* "This product includes software developed by +* Jive Software (http://www.jivesoftware.com)." +* Alternately, this acknowledgment may appear in the software itself, +* if and wherever such third-party acknowledgments normally appear. +* +* 4. The names "Smack" and "Jive Software" must not be used to +* endorse or promote products derived from this software without +* prior written permission. For written permission, please +* contact webmaster@jivesoftware.com. +* +* 5. Products derived from this software may not be called "Smack", +* nor may "Smack" appear in their name, without prior written +* permission of Jive Software. +* +* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL JIVE SOFTWARE OR +* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +* SUCH DAMAGE. +* ==================================================================== +*/ + +package org.jivesoftware.smackx.workgroup.packet; + +import java.util.Date; + +/** + * An immutable class which wraps up customer-in-queue data return from the server; depending on + * the type of information dispatched from the server, not all information will be available in + * any given instance. + * + * @author loki der quaeler + */ +public class QueueUser { + + private String userID; + + private int queuePosition; + private int estimatedTime; + private Date joinDate; + + /** + * @param uid the user jid of the customer in the queue + * @param position the position customer sits in the queue + * @param time the estimate of how much longer the customer will be in the queue in seconds + * @param joinedAt the timestamp of when the customer entered the queue + */ + public QueueUser (String uid, int position, int time, Date joinedAt) { + super(); + + this.userID = uid; + this.queuePosition = position; + this.estimatedTime = time; + this.joinDate = joinedAt; + } + + /** + * @return the user jid of the customer in the queue + */ + public String getUserID () { + return this.userID; + } + + /** + * @return the position in the queue at which the customer sits, or -1 if the update which + * this instance embodies is only a time update instead + */ + public int getQueuePosition () { + return this.queuePosition; + } + + /** + * @return the estimated time remaining of the customer in the queue in seconds, or -1 if + * if the update which this instance embodies is only a position update instead + */ + public int getEstimatedRemainingTime () { + return this.estimatedTime; + } + + /** + * @return the timestamp of when this customer entered the queue, or null if the server did not + * provide this information + */ + public Date getQueueJoinTimestamp () { + return this.joinDate; + } + +} diff --git a/source/org/jivesoftware/smackx/workgroup/packet/SessionID.java b/source/org/jivesoftware/smackx/workgroup/packet/SessionID.java index ef712e05b..69bb6fcb1 100644 --- a/source/org/jivesoftware/smackx/workgroup/packet/SessionID.java +++ b/source/org/jivesoftware/smackx/workgroup/packet/SessionID.java @@ -1,3 +1,55 @@ +/** +* $RCSfile$ +* $Revision$ +* $Date$ +* +* Copyright (C) 2002-2004 Jive Software. All rights reserved. +* ==================================================================== +* The Jive Software License (based on Apache Software License, Version 1.1) +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* +* 3. The end-user documentation included with the redistribution, +* if any, must include the following acknowledgment: +* "This product includes software developed by +* Jive Software (http://www.jivesoftware.com)." +* Alternately, this acknowledgment may appear in the software itself, +* if and wherever such third-party acknowledgments normally appear. +* +* 4. The names "Smack" and "Jive Software" must not be used to +* endorse or promote products derived from this software without +* prior written permission. For written permission, please +* contact webmaster@jivesoftware.com. +* +* 5. Products derived from this software may not be called "Smack", +* nor may "Smack" appear in their name, without prior written +* permission of Jive Software. +* +* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL JIVE SOFTWARE OR +* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +* SUCH DAMAGE. +* ==================================================================== +*/ + package org.jivesoftware.smackx.workgroup.packet; import org.jivesoftware.smack.packet.PacketExtension; diff --git a/source/org/jivesoftware/smackx/workgroup/packet/WorkgroupInformation.java b/source/org/jivesoftware/smackx/workgroup/packet/WorkgroupInformation.java index e855066e4..20a0af48a 100644 --- a/source/org/jivesoftware/smackx/workgroup/packet/WorkgroupInformation.java +++ b/source/org/jivesoftware/smackx/workgroup/packet/WorkgroupInformation.java @@ -1,3 +1,55 @@ +/** +* $RCSfile$ +* $Revision$ +* $Date$ +* +* Copyright (C) 2002-2004 Jive Software. All rights reserved. +* ==================================================================== +* The Jive Software License (based on Apache Software License, Version 1.1) +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* +* 3. The end-user documentation included with the redistribution, +* if any, must include the following acknowledgment: +* "This product includes software developed by +* Jive Software (http://www.jivesoftware.com)." +* Alternately, this acknowledgment may appear in the software itself, +* if and wherever such third-party acknowledgments normally appear. +* +* 4. The names "Smack" and "Jive Software" must not be used to +* endorse or promote products derived from this software without +* prior written permission. For written permission, please +* contact webmaster@jivesoftware.com. +* +* 5. Products derived from this software may not be called "Smack", +* nor may "Smack" appear in their name, without prior written +* permission of Jive Software. +* +* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL JIVE SOFTWARE OR +* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +* SUCH DAMAGE. +* ==================================================================== +*/ + package org.jivesoftware.smackx.workgroup.packet; import org.jivesoftware.smack.packet.PacketExtension; diff --git a/source/org/jivesoftware/smackx/workgroup/user/QueueListener.java b/source/org/jivesoftware/smackx/workgroup/user/QueueListener.java index d17166ba5..597e5b686 100644 --- a/source/org/jivesoftware/smackx/workgroup/user/QueueListener.java +++ b/source/org/jivesoftware/smackx/workgroup/user/QueueListener.java @@ -1,13 +1,54 @@ /** - * $RCSfile$ - * $Revision$ - * $Date$ - * - * Copyright (C) 1999-2003 Jive Software. All rights reserved. - * - * This software is the proprietary information of Jive Software. - * Use is subject to license terms. - */ +* $RCSfile$ +* $Revision$ +* $Date$ +* +* Copyright (C) 2002-2004 Jive Software. All rights reserved. +* ==================================================================== +* The Jive Software License (based on Apache Software License, Version 1.1) +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* +* 3. The end-user documentation included with the redistribution, +* if any, must include the following acknowledgment: +* "This product includes software developed by +* Jive Software (http://www.jivesoftware.com)." +* Alternately, this acknowledgment may appear in the software itself, +* if and wherever such third-party acknowledgments normally appear. +* +* 4. The names "Smack" and "Jive Software" must not be used to +* endorse or promote products derived from this software without +* prior written permission. For written permission, please +* contact webmaster@jivesoftware.com. +* +* 5. Products derived from this software may not be called "Smack", +* nor may "Smack" appear in their name, without prior written +* permission of Jive Software. +* +* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL JIVE SOFTWARE OR +* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +* SUCH DAMAGE. +* ==================================================================== +*/ package org.jivesoftware.smackx.workgroup.user; diff --git a/source/org/jivesoftware/smackx/workgroup/user/Workgroup.java b/source/org/jivesoftware/smackx/workgroup/user/Workgroup.java index 2c392d045..e26146b3b 100644 --- a/source/org/jivesoftware/smackx/workgroup/user/Workgroup.java +++ b/source/org/jivesoftware/smackx/workgroup/user/Workgroup.java @@ -1,13 +1,54 @@ /** - * $RCSfile$ - * $Revision$ - * $Date$ - * - * Copyright (C) 1999-2003 Jive Software. All rights reserved. - * - * This software is the proprietary information of Jive Software. - * Use is subject to license terms. - */ +* $RCSfile$ +* $Revision$ +* $Date$ +* +* Copyright (C) 2002-2004 Jive Software. All rights reserved. +* ==================================================================== +* The Jive Software License (based on Apache Software License, Version 1.1) +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* +* 3. The end-user documentation included with the redistribution, +* if any, must include the following acknowledgment: +* "This product includes software developed by +* Jive Software (http://www.jivesoftware.com)." +* Alternately, this acknowledgment may appear in the software itself, +* if and wherever such third-party acknowledgments normally appear. +* +* 4. The names "Smack" and "Jive Software" must not be used to +* endorse or promote products derived from this software without +* prior written permission. For written permission, please +* contact webmaster@jivesoftware.com. +* +* 5. Products derived from this software may not be called "Smack", +* nor may "Smack" appear in their name, without prior written +* permission of Jive Software. +* +* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL JIVE SOFTWARE OR +* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +* SUCH DAMAGE. +* ==================================================================== +*/ package org.jivesoftware.smackx.workgroup.user; @@ -18,12 +59,11 @@ import org.jivesoftware.smack.filter.*; import org.jivesoftware.smack.packet.*; import org.jivesoftware.smackx.GroupChatInvitation; -import org.jivesoftware.smackx.workgroup.*; import org.jivesoftware.smackx.workgroup.packet.*; import org.jivesoftware.smackx.workgroup.util.MetaDataUtils; /** - * Provides workgroup services for users. Users can join the workgropu queue, depart the + * Provides workgroup services for users. Users can join the workgroup queue, depart the * queue, find status information about their placement in the queue, and register to * be notified when they are routed to an agent.
*
@@ -31,19 +71,19 @@ import org.jivesoftware.smackx.workgroup.util.MetaDataUtils;
* for use by agents.
*
* @author Matt Tucker
- * @author loki der quaeler
*/
public class Workgroup {
private String workgroupName;
private XMPPConnection connection;
private boolean inQueue;
- private List invitationListeners;
private List queueListeners;
private int queuePosition = -1;
private int queueRemainingTime = -1;
+ private PacketListener packetListener;
+
/**
* Creates a new workgroup instance using the specified workgroup name
* (eg support@example.com) and XMPP connection. The connection must have
@@ -63,7 +103,6 @@ public class Workgroup {
this.workgroupName = workgroupName;
this.connection = connection;
inQueue = false;
- invitationListeners = new ArrayList();
queueListeners = new ArrayList();
// Register as a queue listener for internal usage by this instance.
@@ -88,11 +127,16 @@ public class Workgroup {
});
// Register an invitation listener for internal usage by this instance.
- addInvitationListener(new InvitationListener() {
- public void invitationReceived(Invitation invitation) {
- inQueue = false;
- queuePosition = -1;
- queueRemainingTime = -1;
+ addInvitationListener(new PacketListener() {
+
+ public void processPacket(Packet packet) {
+ GroupChatInvitation invitation = (GroupChatInvitation)packet.getExtension(
+ GroupChatInvitation.ELEMENT_NAME, GroupChatInvitation.NAMESPACE);
+ if (invitation != null) {
+ inQueue = false;
+ queuePosition = -1;
+ queueRemainingTime = -1;
+ }
}
});
@@ -102,11 +146,13 @@ public class Workgroup {
PacketFilter filter = new AndFilter(new FromContainsFilter(this.workgroupName), orFilter);
- connection.addPacketListener(new PacketListener() {
- public void processPacket(Packet packet) {
- handlePacket(packet);
- }
- }, filter);
+ packetListener = new PacketListener() {
+
+ public void processPacket(Packet packet) {
+ handlePacket(packet);
+ }
+ };
+ connection.addPacketListener(packetListener, filter);
}
/**
@@ -306,34 +352,14 @@ public class Workgroup {
* Adds an invitation listener that will be notified of groupchat invitations
* from the workgroup for the the user that created this Workgroup instance.
*
- * @param invitationListener the invitation listener.
+ * @param packetListener the invitation listener.
*/
- public void addInvitationListener(InvitationListener invitationListener) {
- synchronized(invitationListeners) {
- if (!invitationListeners.contains(invitationListener)) {
- invitationListeners.add(invitationListener);
- }
- }
+ public void addInvitationListener(PacketListener packetListener) {
+ connection.addPacketListener(packetListener, null);
}
- /**
- * Removes an invitation listener.
- *
- * @param invitationListener the invitation listener.
- */
- public void removeQueueListener(InvitationListener invitationListener) {
- synchronized(invitationListeners) {
- invitationListeners.remove(invitationListener);
- }
- }
-
- private void fireInvitationEvent(Invitation invitation) {
- synchronized (invitationListeners) {
- for (Iterator i=invitationListeners.iterator(); i.hasNext(); ) {
- InvitationListener listener = (InvitationListener)i.next();
- listener.invitationReceived(invitation);
- }
- }
+ protected void finalize() throws Throwable {
+ connection.removePacketListener(packetListener);
}
private void fireQueueJoinedEvent() {
@@ -383,35 +409,6 @@ public class Workgroup {
if (pe != null) {
fireQueueDepartedEvent();
}
- else {
- // Check to see if the user has been invited to a chat.
- GroupChatInvitation invitation = (GroupChatInvitation)msg.getExtension(
- "x", "jabber:x:conference");
-
- if (invitation != null) {
- String roomAddress = invitation.getRoomAddress();
- String sessionID = null;
- Map metaData = null;
-
- pe = msg.getExtension(SessionID.ELEMENT_NAME,
- SessionID.NAMESPACE);
- if (pe != null) {
- sessionID = ((SessionID)pe).getSessionID();
- }
-
- pe = msg.getExtension(MetaData.ELEMENT_NAME,
- MetaData.NAMESPACE);
- if (pe != null) {
- metaData = ((MetaData)pe).getMetaData();
- }
-
- Invitation inv = new Invitation(connection.getUser(), roomAddress,
- workgroupName, sessionID, msg.getBody(),
- msg.getFrom(), metaData);
-
- fireInvitationEvent(inv);
- }
- }
}
// Check to see if it's a queue update notification.
else if (packet instanceof QueueUpdate) {
@@ -446,7 +443,7 @@ public class Workgroup {
buf.append("