diff --git a/apps/webchat/build/ant b/apps/webchat/build/ant
deleted file mode 100644
index b4319cf79..000000000
--- a/apps/webchat/build/ant
+++ /dev/null
@@ -1,42 +0,0 @@
-#! /bin/sh
-
-# //--------------------------------------------------------------------------//
-# // $RCSfile$
-# // $Revision$
-# // $Date$
-# //
-# // Standard Jive Software ant file. Do not change this file. If you do,
-# // you will have seven years of bad luck and bad builds.
-# //--------------------------------------------------------------------------//
-
-# //--------------------------------------------------------------------------//
-# // Uncomment the following lines if you wish to set JAVA_HOME in this script
-# //--------------------------------------------------------------------------//
-# JAVA_HOME=
-# EXPORT JAVA_HOME
-
-# //--------------------------------------------------------------------------//
-# // Check for the JAVA_HOME environment variable //
-# //--------------------------------------------------------------------------//
-if [ "$JAVA_HOME" != "" ] ; then
- # //----------------------------------------------------------------------//
- # // Create Ant's classpath //
- # //----------------------------------------------------------------------//
- CP=$JAVA_HOME/lib/tools.jar:../../../build/ant.jar
-
- # //----------------------------------------------------------------------//
- # // Run ant //
- # //----------------------------------------------------------------------//
- $JAVA_HOME/bin/java -classpath $CP -Dant.home=. org.apache.tools.ant.Main $@
-else
- # //----------------------------------------------------------------------//
- # // No JAVA_HOME error message //
- # //----------------------------------------------------------------------//
- echo "Jive Forums Build Error:"
- echo ""
- echo "The JAVA_HOME environment variable is not set. JAVA_HOME should point"
- echo "to your java directory, ie: /usr/local/bin/jdk1.3. You can set"
- echo "this via the command line like so:"
- echo " export JAVA_HOME=/usr/local/bin/jdk1.3"
-fi
-
diff --git a/apps/webchat/build/ant.bat b/apps/webchat/build/ant.bat
deleted file mode 100644
index fcbd96e70..000000000
--- a/apps/webchat/build/ant.bat
+++ /dev/null
@@ -1,52 +0,0 @@
-@echo off
-
-rem //------------------------------------------------------------------------//
-rem // $RCSfile$
-rem // $Revision$
-rem // $Date$
-rem //
-rem // Standard Jive Software ant.bat file. Do not change this file. If you do,
-rem // you will have seven years of bad luck and bad builds.
-rem //------------------------------------------------------------------------//
-
-rem //------------------------------------------------------------------------//
-rem // Uncomment the following if you wish to set JAVA_HOME in this bat file:
-rem //------------------------------------------------------------------------//
-rem SET JAVA_HOME=
-
-rem //------------------------------------------------------------------------//
-rem // Check for the JAVA_HOME environment variable
-rem //------------------------------------------------------------------------//
-if "%JAVA_HOME%" == "" goto noJavaHome
-
-rem //------------------------------------------------------------------------//
-rem // Make the correct classpath (should include the java jars and the
-rem // Ant jars)
-rem //------------------------------------------------------------------------//
-SET CP=%JAVA_HOME%\lib\tools.jar;..\..\..\build\ant.jar
-
-rem //------------------------------------------------------------------------//
-rem // Run Ant
-rem // Note for Win 98/95 users: You need to change "%*" in the following
-rem // line to be "%1 %2 %3 %4 %5 %6 %7 %8 %9"
-rem //------------------------------------------------------------------------//
-
-%JAVA_HOME%\bin\java -Xms32m -Xmx128m -classpath %CP% -Dant.home=. org.apache.tools.ant.Main %*
-goto end
-
-rem //------------------------------------------------------------------------//
-rem // Error message for missing JAVA_HOME
-rem //------------------------------------------------------------------------//
-:noJavaHome
-echo.
-echo Jive Forums Build Error:
-echo.
-echo The JAVA_HOME environment variable is not set. JAVA_HOME should point to
-echo your java directory, ie: c:\jdk1.3.1. You can set this via the command
-echo line like so:
-echo SET JAVA_HOME=c:\jdk1.3
-echo.
-goto end
-
-:end
-
diff --git a/apps/webchat/build/build.xml b/apps/webchat/build/build.xml
deleted file mode 100644
index eb9095f21..000000000
--- a/apps/webchat/build/build.xml
+++ /dev/null
@@ -1,91 +0,0 @@
-
-
-
-
-
- * - * The filter must be configured with information about where the image files - * are located. A table containing all the supported emoticons with their - * ASCII representations and image file names is as follows:
- * - *
Emotion | ASCII | Image |
Happy | :) or :-) | happy.gif |
Sad | :( or :-( | sad.gif |
Grin | :D | grin.gif |
Love | :x | love.gif |
Mischief | ;\ | mischief.gif |
Cool | B-) | cool.gif |
Devil | ]:) | devil.gif |
Silly | :p | silly.gif |
Angry | X-( | angry.gif |
Laugh | :^O | laugh.gif |
Wink | ;) or ;-) | wink.gif |
Blush | :8} | blush.gif |
Cry | :_| | cry.gif |
Confused | ?:| | confused.gif |
Shocked | :O | shocked.gif |
Plain | :| | plain.gif |
", preformatStartCount); - string = replaceIgnoreCase(string, "[/pre]", "", preformatEndCount); - int preStartCount = preformatStartCount[0]; - int preEndCount = preformatEndCount[0]; - - while (preStartCount > preEndCount) { - string = string.concat(""); - preEndCount++; - } - - return string; - } - - /** - * Replaces all instances of oldString with newString in line with the - * added feature that matches of newString in oldString ignore case. - * The count paramater is set to the number of replaces performed. - * - * @param line the String to search to perform replacements on - * @param oldString the String that should be replaced by newString - * @param newString the String that will replace all instances of oldString - * @param count a value that will be updated with the number of replaces - * performed. - * - * @return a String will all instances of oldString replaced by newString - */ - private static final String replaceIgnoreCase(String line, String oldString, - String newString, int [] count) - { - if (line == null) { - return null; - } - String lcLine = line.toLowerCase(); - String lcOldString = oldString.toLowerCase(); - int i=0; - if ((i=lcLine.indexOf(lcOldString, i)) >= 0) { - int counter = 1; - char [] line2 = line.toCharArray(); - char [] newString2 = newString.toCharArray(); - int oLength = oldString.length(); - StringBuffer buf = new StringBuffer(line2.length); - buf.append(line2, 0, i).append(newString2); - i += oLength; - int j = i; - while ((i=lcLine.indexOf(lcOldString, i)) > 0) { - counter++; - buf.append(line2, j, i-j).append(newString2); - i += oLength; - j = i; - } - buf.append(line2, j, line2.length - j); - count[0] = counter; - return buf.toString(); - } - return line; - } -} \ No newline at end of file diff --git a/apps/webchat/source/java/org/jivesoftware/webchat/URLFilter.java b/apps/webchat/source/java/org/jivesoftware/webchat/URLFilter.java deleted file mode 100644 index de2f972b5..000000000 --- a/apps/webchat/source/java/org/jivesoftware/webchat/URLFilter.java +++ /dev/null @@ -1,312 +0,0 @@ -/** - * $RCSfile$ - * $Revision$ - * $Date$ - * - * Copyright (C) 1999-2002 CoolServlets, Inc. All rights reserved. - * - * This software is the proprietary information of CoolServlets, Inc. - * Use is subject to license terms. - */ - -package org.jivesoftware.webchat; - -import java.util.*; - -/** - * A Filter that converts URL's to working HTML web links.
- *
- * The default set of patterns recognized are ftp://path-of-url
,
- * http://path-of-url
, https://path-of-url
but can be expanded upon.
- *
- * In addition, the following patterns are also recognized.
- *
- * [url path-of-url]descriptive text[/url]
and
- * [url=path-of-url]descriptive text[/url]
.
- *
- * The [url]
allows any path to be defined as link.
- */
-public class URLFilter{
-
- private ArrayList schemes = new ArrayList();
-
- // define a preset default set of schemes
- public URLFilter() {
- schemes.add("http://");
- schemes.add("https://");
- schemes.add("ftp://");
- }
-
- public String applyFilter(String string) {
- if (string == null || string.length() == 0) {
- return string;
- }
-
- int length = string.length();
- StringBuffer filtered = new StringBuffer((int) (length * 1.5));
- ArrayList urlBlocks = new ArrayList(5);
-
- // search for url's such as [url=..]text[/url] or [url ..]text[/url]
- int start = string.indexOf("[url");
- while (start != -1 && (start + 5 < length)) {
- // check to verify we're not in another block
- if (withinAnotherBlock(urlBlocks, start)) {
- start = string.indexOf("[url", start + 5);
- continue;
- }
-
- int end = string.indexOf("[/url]", start + 5);
-
- if (end == -1 || end >= length) {
- // went past end of string, skip
- break;
- }
-
- String u = string.substring(start, end + 6);
- int startTagClose = u.indexOf(']');
- String url;
- String description;
- if (startTagClose > 5) {
- url = u.substring(5, startTagClose);
- description = u.substring(startTagClose + 1, u.length() - 6);
-
- // Check the user entered URL for a "javascript:" or "file:" link. Only
- // append the user entered link if it doesn't contain 'javascript:' and 'file:'
- String lcURL = url.toLowerCase();
- if (lcURL.indexOf("javascript:") == -1 && lcURL.indexOf("file:") == -1) {
- URLBlock block = new URLBlock(start, end + 5, url, description);
- urlBlocks.add(block);
- }
- }
- else {
- url = description = u.substring(startTagClose + 1, u.length() - 6);
- // Check the user entered URL for a "javascript:" or "file:" link. Only
- // append the user entered link if it doesn't contain 'javascript:' and 'file:'
- String lcURL = url.toLowerCase();
- if (lcURL.indexOf("javascript:") == -1 && lcURL.indexOf("file:") == -1) {
- URLBlock block = new URLBlock(start, end + 5, url);
- urlBlocks.add(block);
- }
- }
-
- start = string.indexOf("[url", end + 6);
- }
-
- // now handle all the other urls
- Iterator iter = schemes.iterator();
-
- while (iter.hasNext()) {
- String scheme = (String) iter.next();
- start = string.indexOf(scheme, 0);
-
- while (start != -1) {
- int end = start;
-
- // check context, don't handle patterns preceded by any of '"<=
- if (start > 0) {
- char c = string.charAt(start - 1);
-
- if (c == '\'' || c == '"' || c == '<' || c == '=') {
- start = string.indexOf(scheme, start + scheme.length());
- continue;
- }
- }
-
- // check to verify we're not in another block
- if (withinAnotherBlock(urlBlocks, start)) {
- start = string.indexOf(scheme, start + scheme.length());
- continue;
- }
-
- // find the end of the url
- int cur = start + scheme.length();
- while (end == start && cur < length) {
- char c = string.charAt(cur);
-
- switch (c) {
- case ' ':
- end = cur;
- break;
- case '\t':
- end = cur;
- break;
- case '\'':
- end = cur;
- break;
- case '\"':
- end = cur;
- break;
- case '<':
- end = cur;
- break;
- case '[':
- end = cur;
- break;
- case '\n':
- end = cur;
- break;
- case '\r':
- end = cur;
- break;
- default:
- // acceptable character
- }
-
- cur++;
- }
-
- // if this is true it means the url goes to the end of the string
- if (end == start) {
- end = length - 1;
- }
-
- URLBlock block = new URLBlock(start, end-1, string.substring(start, end));
- urlBlocks.add(block);
-
- start = string.indexOf(scheme, end);
- }
- }
-
- // sort the blocks so that they are in start index order
- sortBlocks(urlBlocks);
-
- // now, markup the urls and pass along the filter chain the rest
- Iterator blocks = urlBlocks.iterator();
- int last = 0;
-
- while (blocks.hasNext()) {
- URLBlock block = (URLBlock) blocks.next();
-
- if (block.getStart() > 0) {
- filtered.append(string.substring(last, block.getStart()));
- }
-
- last = block.getEnd() + 1;
-
- filtered.append("");
- if (block.getDescription().length() > 0) {
- filtered.append(block.getDescription());
- }
- else {
- filtered.append(block.getUrl());
- }
- filtered.append("");
- }
-
- if (last < string.length() - 1) {
- filtered.append(string.substring(last));
- }
-
- return filtered.toString();
- }
-
- /**
- * Returns the current supported uri schemes as a comma seperated string.
- *
- * @return the current supported uri schemes as a comma seperated string.
- */
- public String getSchemes() {
- StringBuffer buf = new StringBuffer(50);
-
- for (int i = 0; i < schemes.size(); i++) {
- buf.append((String) schemes.get(i)).append(",");
- }
- buf.deleteCharAt(buf.length() - 1);
-
- return buf.toString();
- }
-
- /**
- * Sets the current supported uri schemes as a comma seperated string.
- *
- * @param schemes a comma seperated string of uri schemes.
- */
- public void setSchemes(String schemes) {
- if (schemes == null) {
- return;
- }
-
- // enpty the current list
- this.schemes.clear();
-
- StringTokenizer st = new StringTokenizer(schemes, ",");
-
- while (st.hasMoreElements()) {
- this.schemes.add(st.nextElement());
- }
- }
-
- private void sortBlocks(ArrayList blocks) {
- Collections.sort(blocks, new Comparator() {
- public int compare(Object object1, Object object2) {
- URLBlock b1 = (URLBlock) object1;
- URLBlock b2 = (URLBlock) object2;
- return (b1.getStart() > b2.getStart()) ? 1 : -1;
- }
- });
- }
-
- private boolean withinAnotherBlock(List blocks, int start) {
- for (int i = 0; i < blocks.size(); i++) {
- URLBlock block = (URLBlock) blocks.get(i);
-
- if (start >= block.getStart() && start < block.getEnd()) {
- return true;
- }
- }
-
- return false;
- }
-
- class URLBlock {
- int start = 0;
- int end = 0;
- String description = "";
- String url = "";
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getUrl() {
- return url;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
- URLBlock(int start, int end, String url) {
- this.start = start;
- this.end = end;
- this.url = url;
- }
-
- URLBlock(int start, int end, String url, String description) {
- this.start = start;
- this.end = end;
- this.description = description;
- this.url = url;
- }
-
- public int getStart() {
- return start;
- }
-
- public void setStart(int start) {
- this.start = start;
- }
-
- public int getEnd() {
- return end;
- }
-
- public void setEnd(int end) {
- this.end = end;
- }
- }
-}
\ No newline at end of file
diff --git a/apps/webchat/source/java/org/jivesoftware/webchat/URLTranscoder.java b/apps/webchat/source/java/org/jivesoftware/webchat/URLTranscoder.java
deleted file mode 100644
index 84310eca0..000000000
--- a/apps/webchat/source/java/org/jivesoftware/webchat/URLTranscoder.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/**
- * $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.webchat;
-
-import java.util.*;
-
-/**
- * This is a really good example of why software development projects have frameworks, and the
- * other apps in their own modules that sit on top of the frameworks... this class should not
- * be confused with com.jivesoftware.messenger.operator.util.URLTranscoder, which does a
- * variant of the functionality found here.
- *
- * The default set of patterns recognized are ftp://path-of-url
,
- * http://path-of-url
, https://path-of-url
but can be expanded upon.
- *
- * This was originally URLTranscoder, from CoolServlets, but that class did basically nothing that
- * i wanted, so i kept the schemes collection and that was about it.
- *
- * @author loki der quaeler
- */
-public class URLTranscoder {
-
- static protected final String A_HREF_PREFIX = "";
- static protected final String A_HREF_CLOSING_TAG = "";
-
-
- protected ArrayList schemes;
-
- public URLTranscoder () {
- super();
-
- this.schemes = new ArrayList();
-
- this.schemes.add("http://");
- this.schemes.add("https://");
- this.schemes.add("ftp://");
- }
-
- /**
- * Sets the current supported uri schemes.
- *
- * @param schemeCollection a collection of String instances of uri schemes.
- */
- public synchronized void setSchemes (Collection schemeCollection) {
- // MAY EXIT THIS BLOCK
- if (schemes == null) {
- return;
- }
-
- this.schemes.clear();
-
- this.schemes.addAll(schemeCollection);
- }
-
- /**
- * Returns a String based off the original text, but now with any a.href blocks html-ized
- * inside. (for example, supplying the string "this: http://dict.leo.org/ is a cool url"
- * returns "this: http://dict.leo.org/
- * is a cool url"
- */
- public String encodeURLsInText (String text) {
- StringBuffer rhett = null;;
- List runs = this.getURLRunsInString(text);
- Iterator it = null;
- int lastStart = 0;
-
- // MAY RETURN THIS BLOCK
- if (runs.size() == 0) {
- return text;
- }
-
- rhett = new StringBuffer();
- it = runs.iterator();
- while (it.hasNext()) {
- URLRun run = (URLRun)it.next();
- String url = text.substring(run.getStartIndex(), run.getEndIndex());
-
- if (lastStart < run.getStartIndex()) {
- rhett.append(text.substring(lastStart, run.getStartIndex()));
-
- lastStart += run.getEndIndex();
- }
-
- rhett.append(A_HREF_PREFIX).append(url).append(A_HREF_SUFFIX).append(url);
- rhett.append(A_HREF_CLOSING_TAG);
- }
-
- if (lastStart < text.length()) {
- rhett.append(text.substring(lastStart, text.length()));
- }
-
- return rhett.toString();
- }
-
- protected List getURLRunsInString (String text) {
- ArrayList rhett = new ArrayList();
- Vector vStarts = new Vector();
- Iterator sIt = this.schemes.iterator();
- Integer[] iStarts = null;
- char[] tArray = null;
-
- while (sIt.hasNext()) {
- String scheme = (String)sIt.next();
- int index = text.indexOf(scheme);
-
- while (index != -1) {
- vStarts.add(new Integer(index));
-
- index = text.indexOf(scheme, (index + 1));
- }
- }
-
- // MAY RETURN THIS BLOCK
- if (vStarts.size() == 0) {
- return rhett;
- }
-
- iStarts = (Integer[])vStarts.toArray(new Integer[0]);
- Arrays.sort(iStarts);
-
- tArray = text.toCharArray();
-
- for (int i = 0; i < iStarts.length; i++) {
- int start = iStarts[i].intValue();
- int end = start + 1;
-
- while ((end < tArray.length) && (! this.characterIsURLTerminator(tArray[end]))) {
- end++;
- }
-
- if (end == tArray.length) {
- end--;
- }
-
- rhett.add(new URLRun(start, end));
- }
-
- return rhett;
- }
-
- protected boolean characterIsURLTerminator (char c) {
- switch (c) {
- case ' ':
- case '\n':
- case '(':
- case ')':
- case '>':
- case '\t':
- case '\r': return true;
- }
-
- return false;
- }
-
-
- protected class URLRun {
-
- protected int start;
- protected int end;
-
- protected URLRun (int s, int e) {
- super();
-
- this.start = s;
- this.end = e;
- }
-
- protected int getStartIndex () {
- return this.start;
- }
-
- protected int getEndIndex () {
- return this.end;
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/apps/webchat/source/web/account_creation.jsp b/apps/webchat/source/web/account_creation.jsp
deleted file mode 100644
index b30e1f503..000000000
--- a/apps/webchat/source/web/account_creation.jsp
+++ /dev/null
@@ -1,116 +0,0 @@
-<%--
- -
- -
---%>
-
-<%@ page import="java.util.*" %>
-
-<% // Get error map as a request attribute:
- Map errors = (Map)request.getAttribute("messenger.servlet.errors");
- if (errors == null) { errors = new HashMap(); }
-%>
-
-
-
-
-
-
|
-
-
|
-
- * - * Most XMPP servers use a sub-domain for the chat service (eg chat.example.com - * for the XMPP server example.com). You must ensure that the room address you're - * trying to connect to includes the proper chat sub-domain. - * - * @param connection the XMPP connection. - * @param room the name of the room in the form "roomName@service", where - * "service" is the hostname at which the multi-user chat - * service is running. - */ - public GroupChat(XMPPConnection connection, String room) { - this.connection = connection; - this.room = room; - // Create a collector for all incoming messages. - messageFilter = new AndFilter(new FromContainsFilter(room), - new PacketTypeFilter(Message.class)); - messageFilter = new AndFilter(messageFilter, new PacketFilter() { - public boolean accept(Packet packet) { - Message msg = (Message)packet; - return msg.getType() == Message.Type.GROUP_CHAT; - } - }); - messageCollector = connection.createPacketCollector(messageFilter); - // Create a listener for all presence updates. - presenceFilter = new AndFilter(new FromContainsFilter(room), - new PacketTypeFilter(Presence.class)); - connection.addPacketListener(new PacketListener() { - public void processPacket(Packet packet) { - Presence presence = (Presence)packet; - String from = presence.getFrom(); - if (presence.getType() == Presence.Type.AVAILABLE) { - synchronized (participants) { - if (!participants.contains(from)) { - participants.add(from); - } - } - } - else if (presence.getType() == Presence.Type.UNAVAILABLE) { - synchronized (participants) { - participants.remove(from); - } - } - } - }, presenceFilter); - } - - /** - * Returns the name of the room this GroupChat object represents. - * - * @return the groupchat room name. - */ - public String getRoom() { - return room; - } - - /** - * Joins the chat room using the specified nickname. If already joined - * using another nickname, this method will first leave the room and then - * re-join using the new nickname. The default timeout of 5 seconds for a reply - * from the group chat server that the join succeeded will be used. - * - * @param nickname the nickname to use. - * @throws XMPPException if an error occurs joining the room. In particular, a - * 409 error can occur if someone is already in the group chat with the same - * nickname. - */ - public synchronized void join(String nickname) throws XMPPException { - join(nickname, SmackConfiguration.getPacketReplyTimeout()); - } - - /** - * Joins the chat room using the specified nickname. If already joined as - * another nickname, will leave as that name first before joining under the new - * name. - * - * @param nickname the nickname to use. - * @param timeout the number of milleseconds to wait for a reply from the - * group chat that joining the room succeeded. - * @throws XMPPException if an error occurs joining the room. In particular, a - * 409 error can occur if someone is already in the group chat with the same - * nickname. - */ - public synchronized void join(String nickname, long timeout) throws XMPPException { - if (nickname == null || nickname.equals("")) { - throw new IllegalArgumentException("Nickname must not be null or blank."); - } - // If we've already joined the room, leave it before joining under a new - // nickname. - if (joined) { - leave(); - } - // We join a room by sending a presence packet where the "to" - // field is in the form "roomName@service/nickname" - Presence joinPresence = new Presence(Presence.Type.AVAILABLE); - joinPresence.setTo(room + "/" + nickname); - // Wait for a presence packet back from the server. - PacketFilter responseFilter = new AndFilter( - new FromContainsFilter(room + "/" + nickname), - new PacketTypeFilter(Presence.class)); - PacketCollector response = connection.createPacketCollector(responseFilter); - // Send join packet. - connection.sendPacket(joinPresence); - // Wait up to a certain number of seconds for a reply. - Presence presence = (Presence)response.nextResult(timeout); - response.cancel(); - if (presence == null) { - throw new XMPPException("No response from server."); - } - else if (presence.getError() != null) { - throw new XMPPException(presence.getError()); - } - this.nickname = nickname; - joined = true; - } - - /** - * Returns true if currently in the group chat (after calling the {@link - * #join(String)} method. - * - * @return true if currently in the group chat room. - */ - public boolean isJoined() { - return joined; - } - - /** - * Leave the chat room. - */ - public synchronized void leave() { - // If not joined already, do nothing. - if (!joined) { - return; - } - // We leave a room by sending a presence packet where the "to" - // field is in the form "roomName@service/nickname" - Presence leavePresence = new Presence(Presence.Type.UNAVAILABLE); - leavePresence.setTo(room + "/" + nickname); - connection.sendPacket(leavePresence); - // Reset participant information. - participants = new ArrayList(); - nickname = null; - joined = false; - } - - /** - * Returns the nickname that was used to join the room, or null if not - * currently joined. - * - * @return the nickname currently being used. - */ - public String getNickname() { - return nickname; - } - - /** - * Returns the number of participants in the group chat.
- *
- * Note: this value will only be accurate after joining the group chat, and
- * may fluctuate over time. If you query this value directly after joining the
- * group chat it may not be accurate, as it takes a certain amount of time for
- * the server to send all presence packets to this client.
- *
- * @return the number of participants in the group chat.
- */
- public int getParticipantCount() {
- synchronized (participants) {
- return participants.size();
- }
- }
-
- /**
- * Returns an Iterator (of Strings) for the list of fully qualified participants
- * in the group chat. For example, "conference@chat.jivesoftware.com/SomeUser".
- * Typically, a client would only display the nickname of the participant. To
- * get the nickname from the fully qualified name, use the
- * {@link org.jivesoftware.smack.util.StringUtils#parseResource(String)} method.
- * Note: this value will only be accurate after joining the group chat, and may
- * fluctuate over time.
- *
- * @return an Iterator for the participants in the group chat.
- */
- public Iterator getParticipants() {
- synchronized (participants) {
- return Collections.unmodifiableList(new ArrayList(participants)).iterator();
- }
- }
-
- /**
- * Adds a packet listener that will be notified of any new Presence packets
- * sent to the group chat. Using a listener is a suitable way to know when the list
- * of participants should be re-loaded due to any changes.
- *
- * @param listener a packet listener that will be notified of any presence packets
- * sent to the group chat.
- */
- public void addParticipantListener(PacketListener listener) {
- connection.addPacketListener(listener, presenceFilter);
- connectionListeners.add(listener);
- }
-
- /**
- * Sends a message to the chat room.
- *
- * @param text the text of the message to send.
- * @throws XMPPException if sending the message fails.
- */
- public void sendMessage(String text) throws XMPPException {
- Message message = new Message(room, Message.Type.GROUP_CHAT);
- message.setBody(text);
- connection.sendPacket(message);
- }
-
- /**
- * Creates a new Message to send to the chat room.
- *
- * @return a new Message addressed to the chat room.
- */
- public Message createMessage() {
- return new Message(room, Message.Type.GROUP_CHAT);
- }
-
- /**
- * Sends a Message to the chat room.
- *
- * @param message the message.
- * @throws XMPPException if sending the message fails.
- */
- public void sendMessage(Message message) throws XMPPException {
- connection.sendPacket(message);
- }
-
- /**
- * Polls for and returns the next message, or null if there isn't
- * a message immediately available. This method provides significantly different
- * functionalty than the {@link #nextMessage()} method since it's non-blocking.
- * In other words, the method call will always return immediately, whereas the
- * nextMessage method will return only when a message is available (or after
- * a specific timeout).
- *
- * @return the next message if one is immediately available and
- * null otherwise.
- */
- public Message pollMessage() {
- return (Message)messageCollector.pollResult();
- }
-
- /**
- * Returns the next available message in the chat. The method call will block
- * (not return) until a message is available.
- *
- * @return the next message.
- */
- public Message nextMessage() {
- return (Message)messageCollector.nextResult();
- }
-
- /**
- * Returns the next available message in the chat. The method call will block
- * (not return) until a packet is available or the timeout has elapased.
- * If the timeout elapses without a result, null will be returned.
- *
- * @param timeout the maximum amount of time to wait for the next message.
- * @return the next message, or null if the timeout elapses without a
- * message becoming available.
- */
- public Message nextMessage(long timeout) {
- return (Message)messageCollector.nextResult(timeout);
- }
-
- /**
- * Adds a packet listener that will be notified of any new messages in the
- * group chat. Only "group chat" messages addressed to this group chat will
- * be delivered to the listener. If you wish to listen for other packets
- * that may be associated with this group chat, you should register a
- * PacketListener directly with the XMPPConnection with the appropriate
- * PacketListener.
- *
- * @param listener a packet listener.
- */
- public void addMessageListener(PacketListener listener) {
- connection.addPacketListener(listener, messageFilter);
- connectionListeners.add(listener);
- }
-
- public void finalize() throws Throwable {
- super.finalize();
- try {
- if (messageCollector != null) {
- messageCollector.cancel();
- }
- // Remove all the PacketListeners added to the connection by this GroupChat
- for (Iterator it=connectionListeners.iterator(); it.hasNext();) {
- connection.removePacketListener((PacketListener) it.next());
- }
- }
- catch (Exception e) {}
- }
-}
\ No newline at end of file
diff --git a/source/org/jivesoftware/smack/PacketCollector.java b/source/org/jivesoftware/smack/PacketCollector.java
index 3f200d7a9..737def22e 100644
--- a/source/org/jivesoftware/smack/PacketCollector.java
+++ b/source/org/jivesoftware/smack/PacketCollector.java
@@ -135,17 +135,34 @@ public class PacketCollector {
public synchronized Packet nextResult(long timeout) {
// Wait up to the specified amount of time for a result.
if (resultQueue.isEmpty()) {
+ long waitTime = timeout;
+ long start = System.currentTimeMillis();
try {
- wait(timeout);
+ // Keep waiting until the specified amount of time has elapsed, or
+ // a packet is available to return.
+ while (resultQueue.isEmpty()) {
+ if (waitTime <= 0) {
+ break;
+ }
+ wait(waitTime);
+ long now = System.currentTimeMillis();
+ waitTime -= (now - start);
+ start = now;
+ }
}
catch (InterruptedException ie) {
// Ignore.
}
+ // Still haven't found a result, so return null.
+ if (resultQueue.isEmpty()) {
+ return null;
+ }
+ // Return the packet that was found.
+ else {
+ return (Packet)resultQueue.removeLast();
+ }
}
- // If still no result, return null.
- if (resultQueue.isEmpty()) {
- return null;
- }
+ // There's already a packet waiting, so return it.
else {
return (Packet)resultQueue.removeLast();
}
diff --git a/source/org/jivesoftware/smack/Roster.java b/source/org/jivesoftware/smack/Roster.java
index 9a46fb050..a6ff567e3 100644
--- a/source/org/jivesoftware/smack/Roster.java
+++ b/source/org/jivesoftware/smack/Roster.java
@@ -25,6 +25,7 @@ import org.jivesoftware.smack.filter.*;
import org.jivesoftware.smack.util.StringUtils;
import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
/**
* Represents a user's roster, which is the collection of users a person receives
@@ -68,10 +69,10 @@ public class Roster {
private static int defaultSubscriptionMode = SUBSCRIPTION_ACCEPT_ALL;
private XMPPConnection connection;
- private Map groups;
+ private Map
- * Most XMPP servers use a sub-domain for the chat service (eg chat.example.com
- * for the XMPP server example.com). You must ensure that the room address you're
- * trying to connect to includes the proper chat sub-domain.
- *
- * @param room the fully qualifed name of the room.
- * @return a new GroupChat object.
- */
- public GroupChat createGroupChat(String room) {
- if (!isConnected()) {
- throw new IllegalStateException("Not connected to server.");
- }
- return new GroupChat(this, room);
- }
-
/**
* Returns true if currently connected to the XMPP server.
*
@@ -656,7 +638,7 @@ public class XMPPConnection {
*/
public void close() {
// Set presence to offline.
- packetWriter.sendPacket(new Presence(Presence.Type.UNAVAILABLE));
+ packetWriter.sendPacket(new Presence(Presence.Type.unavailable));
packetReader.shutdown();
packetWriter.shutdown();
// Wait 150 ms for processes to clean-up, then shutdown.
diff --git a/source/org/jivesoftware/smack/packet/Presence.java b/source/org/jivesoftware/smack/packet/Presence.java
index c4f26eda6..5535b7ca0 100644
--- a/source/org/jivesoftware/smack/packet/Presence.java
+++ b/source/org/jivesoftware/smack/packet/Presence.java
@@ -26,16 +26,16 @@ import org.jivesoftware.smack.util.StringUtils;
* Represents XMPP presence packets. Every presence packet has a type, which is one of
* the following values:
*
*
* A number of attributes are optional:
@@ -44,8 +44,9 @@ import org.jivesoftware.smack.util.StringUtils;
*
*
* Presence packets are used for two purposes. First, to notify the server of our
@@ -57,10 +58,10 @@ import org.jivesoftware.smack.util.StringUtils;
*/
public class Presence extends Packet {
- private Type type = Type.AVAILABLE;
+ private Type type = Type.available;
private String status = null;
private int priority = -1;
- private Mode mode = Mode.AVAILABLE;
+ private Mode mode = Mode.available;
/**
* Creates a new presence update. Status, priority, and mode are left un-set.
@@ -179,7 +180,7 @@ public class Presence extends Packet {
if (getFrom() != null) {
buf.append(" from=\"").append(StringUtils.escapeForXML(getFrom())).append("\"");
}
- if (type != Type.AVAILABLE) {
+ if (type != Type.available) {
buf.append(" type=\"").append(type).append("\"");
}
buf.append(">");
@@ -189,7 +190,7 @@ public class Presence extends Packet {
if (priority != -1) {
buf.append("
- *