mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-12-22 20:47:57 +01:00
Use jxmpp-core (0.1.0-alpha1-SNAPSHOT)
fixes also SMACK-570, since jxmpp-core's XmppStringUtil contains the fix for SMACK-570.
This commit is contained in:
parent
8977f5b3f0
commit
f67d655fe7
34 changed files with 84 additions and 896 deletions
|
@ -43,6 +43,13 @@ allprojects {
|
|||
downloadJavadoc = true
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
// Add OSS Sonatype Snapshot repository
|
||||
maven {
|
||||
url 'https://oss.sonatype.org/content/repositories/snapshots'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gradle.taskGraph.whenReady { taskGraph ->
|
||||
|
|
|
@ -2,12 +2,6 @@ description = """\
|
|||
Smack BOSH API.
|
||||
This API is considered beta quality."""
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url 'https://oss.sonatype.org/content/repositories/snapshots'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile project(':smack-core')
|
||||
compile 'org.igniterealtime.jbosh:jbosh:0.8.0'
|
||||
|
|
|
@ -41,7 +41,6 @@ import org.jivesoftware.smack.XMPPException;
|
|||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smack.packet.Presence.Type;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.igniterealtime.jbosh.BOSHClient;
|
||||
import org.igniterealtime.jbosh.BOSHClientConfig;
|
||||
import org.igniterealtime.jbosh.BOSHClientConnEvent;
|
||||
|
@ -270,7 +269,7 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
|
|||
if (response != null) {
|
||||
this.user = response;
|
||||
// Update the serviceName with the one returned by the server
|
||||
setServiceName(StringUtils.parseServer(response));
|
||||
setServiceName(response);
|
||||
} else {
|
||||
this.user = username + "@" + getServiceName();
|
||||
if (resource != null) {
|
||||
|
@ -319,7 +318,7 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
|
|||
// Set the user value.
|
||||
this.user = response;
|
||||
// Update the serviceName with the one returned by the server
|
||||
setServiceName(StringUtils.parseServer(response));
|
||||
setServiceName(response);
|
||||
|
||||
// Set presence to online.
|
||||
if (config.isSendPresence()) {
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
description = """\
|
||||
Smack core components."""
|
||||
|
||||
ext {
|
||||
jxmppVersion = "0.1.0-alpha1-SNAPSHOT"
|
||||
}
|
||||
|
||||
configurations {
|
||||
compression
|
||||
dns
|
||||
|
@ -8,6 +12,8 @@ configurations {
|
|||
|
||||
dependencies {
|
||||
compile 'xpp3:xpp3:1.1.4c'
|
||||
compile "org.igniterealtime.jxmpp:jxmpp-core:$jxmppVersion"
|
||||
// compile "org.igniterealtime.jxmpp:jxmpp-jid:$jxmppVersion"
|
||||
testCompile 'junit:junit:4.+'
|
||||
testCompile 'xmlunit:xmlunit:1.5'
|
||||
testCompile 'org.powermock:powermock-module-junit4:1.5.+'
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
|
|||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Registration;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jxmpp.util.XmppStringUtils;
|
||||
|
||||
/**
|
||||
* Allows creation and management of accounts on an XMPP server.
|
||||
|
@ -243,7 +243,7 @@ public class AccountManager extends Manager {
|
|||
reg.setType(IQ.Type.SET);
|
||||
reg.setTo(connection().getServiceName());
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
map.put("username",StringUtils.parseName(connection().getUser()));
|
||||
map.put("username",XmppStringUtils.parseLocalpart(connection().getUser()));
|
||||
map.put("password",newPassword);
|
||||
reg.setAttributes(map);
|
||||
connection().createPacketCollectorAndSend(reg).nextResultOrThrow();
|
||||
|
|
|
@ -37,7 +37,7 @@ import org.jivesoftware.smack.filter.ThreadFilter;
|
|||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.Message.Type;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jxmpp.util.XmppStringUtils;
|
||||
|
||||
/**
|
||||
* The chat manager keeps track of references to all current chats. It will not hold any references
|
||||
|
@ -235,7 +235,7 @@ public class ChatManager extends Manager{
|
|||
Chat chat = new Chat(this, userJID, threadID);
|
||||
threadChats.put(threadID, chat);
|
||||
jidChats.put(userJID, chat);
|
||||
baseJidChats.put(StringUtils.parseBareAddress(userJID), chat);
|
||||
baseJidChats.put(XmppStringUtils.parseBareAddress(userJID), chat);
|
||||
|
||||
for(ChatManagerListener listener : chatManagerListeners) {
|
||||
listener.chatCreated(chat, createdLocally);
|
||||
|
@ -248,7 +248,7 @@ public class ChatManager extends Manager{
|
|||
threadChats.remove(chat.getThreadID());
|
||||
String userJID = chat.getParticipant();
|
||||
jidChats.remove(userJID);
|
||||
baseJidChats.remove(StringUtils.parseBareAddress(userJID));
|
||||
baseJidChats.remove(XmppStringUtils.parseBareAddress(userJID));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -294,7 +294,7 @@ public class ChatManager extends Manager{
|
|||
Chat match = jidChats.get(userJID);
|
||||
|
||||
if (match == null && (matchMode == MatchMode.BARE_JID)) {
|
||||
match = baseJidChats.get(StringUtils.parseBareAddress(userJID));
|
||||
match = baseJidChats.get(XmppStringUtils.parseBareAddress(userJID));
|
||||
}
|
||||
return match;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.jivesoftware.smack.packet.Session;
|
|||
import org.jivesoftware.smack.proxy.ProxyInfo;
|
||||
import org.jivesoftware.smack.util.DNSUtil;
|
||||
import org.jivesoftware.smack.util.dns.HostAddress;
|
||||
import org.jxmpp.util.XmppStringUtils;
|
||||
|
||||
import javax.net.SocketFactory;
|
||||
import javax.net.ssl.SSLContext;
|
||||
|
@ -204,6 +205,7 @@ public class ConnectionConfiguration implements Cloneable {
|
|||
* @param serviceName the XMPP domain of the target server.
|
||||
*/
|
||||
void setServiceName(String serviceName) {
|
||||
serviceName = XmppStringUtils.parseDomain(serviceName);
|
||||
this.serviceName = serviceName;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ import org.jivesoftware.smack.packet.Packet;
|
|||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smack.packet.RosterPacket;
|
||||
import org.jivesoftware.smack.packet.RosterPacket.Item;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jxmpp.util.XmppStringUtils;
|
||||
|
||||
/**
|
||||
* Represents a user's roster, which is the collection of users a person receives
|
||||
|
@ -488,7 +488,7 @@ public class Roster {
|
|||
* or if no presence information is available..
|
||||
*/
|
||||
public Presence getPresence(String user) {
|
||||
String key = getPresenceMapKey(StringUtils.parseBareAddress(user));
|
||||
String key = getPresenceMapKey(XmppStringUtils.parseBareAddress(user));
|
||||
Map<String, Presence> userPresences = presenceMap.get(key);
|
||||
if (userPresences == null) {
|
||||
Presence presence = new Presence(Presence.Type.unavailable);
|
||||
|
@ -548,7 +548,7 @@ public class Roster {
|
|||
*/
|
||||
public Presence getPresenceResource(String userWithResource) {
|
||||
String key = getPresenceMapKey(userWithResource);
|
||||
String resource = StringUtils.parseResource(userWithResource);
|
||||
String resource = XmppStringUtils.parseResource(userWithResource);
|
||||
Map<String, Presence> userPresences = presenceMap.get(key);
|
||||
if (userPresences == null) {
|
||||
Presence presence = new Presence(Presence.Type.unavailable);
|
||||
|
@ -626,7 +626,7 @@ public class Roster {
|
|||
}
|
||||
String key = user;
|
||||
if (!contains(user)) {
|
||||
key = StringUtils.parseBareAddress(user);
|
||||
key = XmppStringUtils.parseBareAddress(user);
|
||||
}
|
||||
return key.toLowerCase(Locale.US);
|
||||
}
|
||||
|
@ -749,7 +749,7 @@ public class Roster {
|
|||
String user = entry.getUser();
|
||||
entries.remove(user);
|
||||
unfiledEntries.remove(entry);
|
||||
presenceMap.remove(StringUtils.parseBareAddress(user));
|
||||
presenceMap.remove(XmppStringUtils.parseBareAddress(user));
|
||||
deletedEntries.add(user);
|
||||
|
||||
for (Entry<String,RosterGroup> e: groups.entrySet()) {
|
||||
|
@ -844,7 +844,7 @@ public class Roster {
|
|||
// it since we now have an online presence.
|
||||
userPresences.remove("");
|
||||
// Add the new presence, using the resources as a key.
|
||||
userPresences.put(StringUtils.parseResource(from), presence);
|
||||
userPresences.put(XmppStringUtils.parseResource(from), presence);
|
||||
// If the user is in the roster, fire an event.
|
||||
RosterEntry entry = entries.get(key);
|
||||
if (entry != null) {
|
||||
|
@ -855,7 +855,7 @@ public class Roster {
|
|||
else if (presence.getType() == Presence.Type.unavailable) {
|
||||
// If no resource, this is likely an offline presence as part of
|
||||
// a roster presence flood. In that case, we store it.
|
||||
if ("".equals(StringUtils.parseResource(from))) {
|
||||
if ("".equals(XmppStringUtils.parseResource(from))) {
|
||||
Map<String, Presence> userPresences;
|
||||
// Get the user presence map
|
||||
if (presenceMap.get(key) == null) {
|
||||
|
@ -872,7 +872,7 @@ public class Roster {
|
|||
Map<String, Presence> userPresences = presenceMap.get(key);
|
||||
// Store the offline presence, as it may include extra information
|
||||
// such as the user being on vacation.
|
||||
userPresences.put(StringUtils.parseResource(from), presence);
|
||||
userPresences.put(XmppStringUtils.parseResource(from), presence);
|
||||
}
|
||||
// If the user is in the roster, fire an event.
|
||||
RosterEntry entry = entries.get(key);
|
||||
|
@ -915,7 +915,7 @@ public class Roster {
|
|||
// Error presence packets from a bare JID mean we invalidate all existing
|
||||
// presence info for the user.
|
||||
else if (presence.getType() == Presence.Type.error &&
|
||||
"".equals(StringUtils.parseResource(from)))
|
||||
"".equals(XmppStringUtils.parseResource(from)))
|
||||
{
|
||||
Map<String, Presence> userPresences;
|
||||
if (!presenceMap.containsKey(key)) {
|
||||
|
@ -1032,7 +1032,7 @@ public class Roster {
|
|||
|
||||
// Roster push (RFC 6121, 2.1.6)
|
||||
// A roster push with a non-empty from not matching our address MUST be ignored
|
||||
String jid = StringUtils.parseBareAddress(connection.getUser());
|
||||
String jid = XmppStringUtils.parseBareAddress(connection.getUser());
|
||||
if (rosterPacket.getFrom() != null &&
|
||||
!rosterPacket.getFrom().equals(jid)) {
|
||||
LOGGER.warning("Ignoring roster push with a non matching 'from' ourJid=" + jid
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
|
|||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.RosterPacket;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jxmpp.util.XmppStringUtils;
|
||||
|
||||
/**
|
||||
* A group of roster entries.
|
||||
|
@ -122,7 +122,7 @@ public class RosterGroup {
|
|||
}
|
||||
// Roster entries never include a resource so remove the resource
|
||||
// if it's a part of the XMPP address.
|
||||
user = StringUtils.parseBareAddress(user);
|
||||
user = XmppStringUtils.parseBareAddress(user);
|
||||
String userLowerCase = user.toLowerCase(Locale.US);
|
||||
synchronized (entries) {
|
||||
for (RosterEntry entry : entries) {
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.jivesoftware.smack.PacketListener;
|
|||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.util.*;
|
||||
import org.jxmpp.util.XmppStringUtils;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
|
@ -172,15 +173,15 @@ public class ConsoleDebugger implements SmackDebugger {
|
|||
}
|
||||
|
||||
public void userHasLogged(String user) {
|
||||
boolean isAnonymous = "".equals(StringUtils.parseName(user));
|
||||
boolean isAnonymous = "".equals(XmppStringUtils.parseLocalpart(user));
|
||||
String title =
|
||||
"User logged (" + connection.hashCode() + "): "
|
||||
+ (isAnonymous ? "" : StringUtils.parseBareAddress(user))
|
||||
+ (isAnonymous ? "" : XmppStringUtils.parseBareAddress(user))
|
||||
+ "@"
|
||||
+ connection.getServiceName()
|
||||
+ ":"
|
||||
+ connection.getPort();
|
||||
title += "/" + StringUtils.parseResource(user);
|
||||
title += "/" + XmppStringUtils.parseResource(user);
|
||||
System.out.println(title);
|
||||
// Add the connection listener to the connection so that the debugger can be notified
|
||||
// whenever the connection is closed.
|
||||
|
|
|
@ -27,6 +27,7 @@ import javax.swing.*;
|
|||
import org.jivesoftware.smack.*;
|
||||
import org.jivesoftware.smack.packet.*;
|
||||
import org.jivesoftware.smack.util.*;
|
||||
import org.jxmpp.util.XmppStringUtils;
|
||||
|
||||
/**
|
||||
* The LiteDebugger is a very simple debugger that allows to debug sent, received and
|
||||
|
@ -303,15 +304,15 @@ public class LiteDebugger implements SmackDebugger {
|
|||
}
|
||||
|
||||
public void userHasLogged(String user) {
|
||||
boolean isAnonymous = "".equals(StringUtils.parseName(user));
|
||||
boolean isAnonymous = "".equals(XmppStringUtils.parseLocalpart(user));
|
||||
String title =
|
||||
"Smack Debug Window -- "
|
||||
+ (isAnonymous ? "" : StringUtils.parseBareAddress(user))
|
||||
+ (isAnonymous ? "" : XmppStringUtils.parseBareAddress(user))
|
||||
+ "@"
|
||||
+ connection.getServiceName()
|
||||
+ ":"
|
||||
+ connection.getPort();
|
||||
title += "/" + StringUtils.parseResource(user);
|
||||
title += "/" + XmppStringUtils.parseResource(user);
|
||||
frame.setTitle(title);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.jivesoftware.smack.filter;
|
|||
import java.util.Locale;
|
||||
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jxmpp.util.XmppStringUtils;
|
||||
|
||||
/**
|
||||
* Filter for packets where the "from" field exactly matches a specified JID. If the specified
|
||||
|
@ -61,7 +61,7 @@ public class FromMatchesFilter implements PacketFilter {
|
|||
* have a from address.
|
||||
*/
|
||||
public static FromMatchesFilter create(String address) {
|
||||
return new FromMatchesFilter(address, "".equals(StringUtils.parseResource(address))) ;
|
||||
return new FromMatchesFilter(address, "".equals(XmppStringUtils.parseResource(address))) ;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -72,7 +72,7 @@ public class FromMatchesFilter implements PacketFilter {
|
|||
* have a from address.
|
||||
*/
|
||||
public static FromMatchesFilter createBare(String address) {
|
||||
address = (address == null) ? null : StringUtils.parseBareAddress(address);
|
||||
address = (address == null) ? null : XmppStringUtils.parseBareAddress(address);
|
||||
return new FromMatchesFilter(address, true);
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ public class FromMatchesFilter implements PacketFilter {
|
|||
// Simplest form of NAMEPREP/STRINGPREP
|
||||
from = from.toLowerCase(Locale.US);
|
||||
if (matchBareJID) {
|
||||
from = StringUtils.parseBareAddress(from);
|
||||
from = XmppStringUtils.parseBareAddress(from);
|
||||
}
|
||||
return from.equals(address);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.logging.Logger;
|
|||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jxmpp.util.XmppStringUtils;
|
||||
|
||||
/**
|
||||
* Filters for packets which are a valid reply to an IQ request.
|
||||
|
@ -102,7 +102,7 @@ public class IQReplyFilter implements PacketFilter {
|
|||
fromFilter.addFilter(FromMatchesFilter.createBare(local));
|
||||
fromFilter.addFilter(FromMatchesFilter.createFull(server));
|
||||
}
|
||||
else if (local != null && to.toLowerCase(Locale.US).equals(StringUtils.parseBareAddress(local))) {
|
||||
else if (local != null && to.toLowerCase(Locale.US).equals(XmppStringUtils.parseBareAddress(local))) {
|
||||
fromFilter.addFilter(FromMatchesFilter.createFull(null));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,253 +37,6 @@ public class StringUtils {
|
|||
public static final String LT_ENCODE = "<";
|
||||
public static final String GT_ENCODE = ">";
|
||||
|
||||
/**
|
||||
* Returns the name portion of a XMPP address. For example, for the
|
||||
* address "matt@jivesoftware.com/Smack", "matt" would be returned. If no
|
||||
* username is present in the address, the empty string will be returned.
|
||||
*
|
||||
* @param XMPPAddress the XMPP address.
|
||||
* @return the name portion of the XMPP address.
|
||||
*/
|
||||
public static String parseName(String XMPPAddress) {
|
||||
if (XMPPAddress == null) {
|
||||
return null;
|
||||
}
|
||||
int atIndex = XMPPAddress.lastIndexOf("@");
|
||||
if (atIndex <= 0) {
|
||||
return "";
|
||||
}
|
||||
else {
|
||||
return XMPPAddress.substring(0, atIndex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the server portion of a XMPP address. For example, for the
|
||||
* address "matt@jivesoftware.com/Smack", "jivesoftware.com" would be returned.
|
||||
* If no server is present in the address, the empty string will be returned.
|
||||
*
|
||||
* @param XMPPAddress the XMPP address.
|
||||
* @return the server portion of the XMPP address.
|
||||
*/
|
||||
public static String parseServer(String XMPPAddress) {
|
||||
if (XMPPAddress == null) {
|
||||
return null;
|
||||
}
|
||||
int atIndex = XMPPAddress.lastIndexOf("@");
|
||||
// If the String ends with '@', return the empty string.
|
||||
if (atIndex + 1 > XMPPAddress.length()) {
|
||||
return "";
|
||||
}
|
||||
int slashIndex = XMPPAddress.indexOf("/");
|
||||
if (slashIndex > 0 && slashIndex > atIndex) {
|
||||
return XMPPAddress.substring(atIndex + 1, slashIndex);
|
||||
}
|
||||
else {
|
||||
return XMPPAddress.substring(atIndex + 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the resource portion of a XMPP address. For example, for the
|
||||
* address "matt@jivesoftware.com/Smack", "Smack" would be returned. If no
|
||||
* resource is present in the address, the empty string will be returned.
|
||||
*
|
||||
* @param XMPPAddress the XMPP address.
|
||||
* @return the resource portion of the XMPP address.
|
||||
*/
|
||||
public static String parseResource(String XMPPAddress) {
|
||||
if (XMPPAddress == null) {
|
||||
return null;
|
||||
}
|
||||
int slashIndex = XMPPAddress.indexOf("/");
|
||||
if (slashIndex + 1 > XMPPAddress.length() || slashIndex < 0) {
|
||||
return "";
|
||||
}
|
||||
else {
|
||||
return XMPPAddress.substring(slashIndex + 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the XMPP address with any resource information removed. For example,
|
||||
* for the address "matt@jivesoftware.com/Smack", "matt@jivesoftware.com" would
|
||||
* be returned.
|
||||
*
|
||||
* @param XMPPAddress the XMPP address.
|
||||
* @return the bare XMPP address without resource information.
|
||||
*/
|
||||
public static String parseBareAddress(String XMPPAddress) {
|
||||
if (XMPPAddress == null) {
|
||||
return null;
|
||||
}
|
||||
int slashIndex = XMPPAddress.indexOf("/");
|
||||
if (slashIndex < 0) {
|
||||
return XMPPAddress;
|
||||
}
|
||||
else if (slashIndex == 0) {
|
||||
return "";
|
||||
}
|
||||
else {
|
||||
return XMPPAddress.substring(0, slashIndex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if jid is a full JID (i.e. a JID with resource part).
|
||||
*
|
||||
* @param jid
|
||||
* @return true if full JID, false otherwise
|
||||
*/
|
||||
public static boolean isFullJID(String jid) {
|
||||
if (parseName(jid).length() <= 0 || parseServer(jid).length() <= 0
|
||||
|| parseResource(jid).length() <= 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes the node portion of a JID according to "JID Escaping" (JEP-0106).
|
||||
* Escaping replaces characters prohibited by node-prep with escape sequences,
|
||||
* as follows:<p>
|
||||
*
|
||||
* <table border="1">
|
||||
* <tr><td><b>Unescaped Character</b></td><td><b>Encoded Sequence</b></td></tr>
|
||||
* <tr><td><space></td><td>\20</td></tr>
|
||||
* <tr><td>"</td><td>\22</td></tr>
|
||||
* <tr><td>&</td><td>\26</td></tr>
|
||||
* <tr><td>'</td><td>\27</td></tr>
|
||||
* <tr><td>/</td><td>\2f</td></tr>
|
||||
* <tr><td>:</td><td>\3a</td></tr>
|
||||
* <tr><td><</td><td>\3c</td></tr>
|
||||
* <tr><td>></td><td>\3e</td></tr>
|
||||
* <tr><td>@</td><td>\40</td></tr>
|
||||
* <tr><td>\</td><td>\5c</td></tr>
|
||||
* </table><p>
|
||||
*
|
||||
* This process is useful when the node comes from an external source that doesn't
|
||||
* conform to nodeprep. For example, a username in LDAP may be "Joe Smith". Because
|
||||
* the <space> character isn't a valid part of a node, the username should
|
||||
* be escaped to "Joe\20Smith" before being made into a JID (e.g. "joe\20smith@example.com"
|
||||
* after case-folding, etc. has been applied).<p>
|
||||
*
|
||||
* All node escaping and un-escaping must be performed manually at the appropriate
|
||||
* time; the JID class will not escape or un-escape automatically.
|
||||
*
|
||||
* @param node the node.
|
||||
* @return the escaped version of the node.
|
||||
*/
|
||||
public static String escapeNode(String node) {
|
||||
if (node == null) {
|
||||
return null;
|
||||
}
|
||||
StringBuilder buf = new StringBuilder(node.length() + 8);
|
||||
for (int i=0, n=node.length(); i<n; i++) {
|
||||
char c = node.charAt(i);
|
||||
switch (c) {
|
||||
case '"': buf.append("\\22"); break;
|
||||
case '&': buf.append("\\26"); break;
|
||||
case '\'': buf.append("\\27"); break;
|
||||
case '/': buf.append("\\2f"); break;
|
||||
case ':': buf.append("\\3a"); break;
|
||||
case '<': buf.append("\\3c"); break;
|
||||
case '>': buf.append("\\3e"); break;
|
||||
case '@': buf.append("\\40"); break;
|
||||
case '\\': buf.append("\\5c"); break;
|
||||
default: {
|
||||
if (Character.isWhitespace(c)) {
|
||||
buf.append("\\20");
|
||||
}
|
||||
else {
|
||||
buf.append(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Un-escapes the node portion of a JID according to "JID Escaping" (JEP-0106).<p>
|
||||
* Escaping replaces characters prohibited by node-prep with escape sequences,
|
||||
* as follows:<p>
|
||||
*
|
||||
* <table border="1">
|
||||
* <tr><td><b>Unescaped Character</b></td><td><b>Encoded Sequence</b></td></tr>
|
||||
* <tr><td><space></td><td>\20</td></tr>
|
||||
* <tr><td>"</td><td>\22</td></tr>
|
||||
* <tr><td>&</td><td>\26</td></tr>
|
||||
* <tr><td>'</td><td>\27</td></tr>
|
||||
* <tr><td>/</td><td>\2f</td></tr>
|
||||
* <tr><td>:</td><td>\3a</td></tr>
|
||||
* <tr><td><</td><td>\3c</td></tr>
|
||||
* <tr><td>></td><td>\3e</td></tr>
|
||||
* <tr><td>@</td><td>\40</td></tr>
|
||||
* <tr><td>\</td><td>\5c</td></tr>
|
||||
* </table><p>
|
||||
*
|
||||
* This process is useful when the node comes from an external source that doesn't
|
||||
* conform to nodeprep. For example, a username in LDAP may be "Joe Smith". Because
|
||||
* the <space> character isn't a valid part of a node, the username should
|
||||
* be escaped to "Joe\20Smith" before being made into a JID (e.g. "joe\20smith@example.com"
|
||||
* after case-folding, etc. has been applied).<p>
|
||||
*
|
||||
* All node escaping and un-escaping must be performed manually at the appropriate
|
||||
* time; the JID class will not escape or un-escape automatically.
|
||||
*
|
||||
* @param node the escaped version of the node.
|
||||
* @return the un-escaped version of the node.
|
||||
*/
|
||||
public static String unescapeNode(String node) {
|
||||
if (node == null) {
|
||||
return null;
|
||||
}
|
||||
char [] nodeChars = node.toCharArray();
|
||||
StringBuilder buf = new StringBuilder(nodeChars.length);
|
||||
for (int i=0, n=nodeChars.length; i<n; i++) {
|
||||
compare: {
|
||||
char c = node.charAt(i);
|
||||
if (c == '\\' && i+2<n) {
|
||||
char c2 = nodeChars[i+1];
|
||||
char c3 = nodeChars[i+2];
|
||||
if (c2 == '2') {
|
||||
switch (c3) {
|
||||
case '0': buf.append(' '); i+=2; break compare;
|
||||
case '2': buf.append('"'); i+=2; break compare;
|
||||
case '6': buf.append('&'); i+=2; break compare;
|
||||
case '7': buf.append('\''); i+=2; break compare;
|
||||
case 'f': buf.append('/'); i+=2; break compare;
|
||||
}
|
||||
}
|
||||
else if (c2 == '3') {
|
||||
switch (c3) {
|
||||
case 'a': buf.append(':'); i+=2; break compare;
|
||||
case 'c': buf.append('<'); i+=2; break compare;
|
||||
case 'e': buf.append('>'); i+=2; break compare;
|
||||
}
|
||||
}
|
||||
else if (c2 == '4') {
|
||||
if (c3 == '0') {
|
||||
buf.append("@");
|
||||
i+=2;
|
||||
break compare;
|
||||
}
|
||||
}
|
||||
else if (c2 == '5') {
|
||||
if (c3 == 'c') {
|
||||
buf.append("\\");
|
||||
i+=2;
|
||||
break compare;
|
||||
}
|
||||
}
|
||||
}
|
||||
buf.append(c);
|
||||
}
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes all necessary characters in the String so that it can be used
|
||||
* in an XML doc.
|
||||
|
|
|
@ -1,325 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright the original author or authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jivesoftware.smack.util;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class XmppDateTime {
|
||||
|
||||
private static final DateFormatType dateFormatter = DateFormatType.XEP_0082_DATE_PROFILE;
|
||||
private static final Pattern datePattern = Pattern.compile("^\\d+-\\d+-\\d+$");
|
||||
|
||||
private static final DateFormatType timeFormatter = DateFormatType.XEP_0082_TIME_MILLIS_ZONE_PROFILE;
|
||||
private static final Pattern timePattern = Pattern.compile("^(\\d+:){2}\\d+.\\d+(Z|([+-](\\d+:\\d+)))$");
|
||||
private static final DateFormatType timeNoZoneFormatter = DateFormatType.XEP_0082_TIME_MILLIS_PROFILE;
|
||||
private static final Pattern timeNoZonePattern = Pattern.compile("^(\\d+:){2}\\d+.\\d+$");
|
||||
|
||||
private static final DateFormatType timeNoMillisFormatter = DateFormatType.XEP_0082_TIME_ZONE_PROFILE;
|
||||
private static final Pattern timeNoMillisPattern = Pattern.compile("^(\\d+:){2}\\d+(Z|([+-](\\d+:\\d+)))$");
|
||||
private static final DateFormatType timeNoMillisNoZoneFormatter = DateFormatType.XEP_0082_TIME_PROFILE;
|
||||
private static final Pattern timeNoMillisNoZonePattern = Pattern.compile("^(\\d+:){2}\\d+$");
|
||||
|
||||
private static final DateFormatType dateTimeFormatter = DateFormatType.XEP_0082_DATETIME_MILLIS_PROFILE;
|
||||
private static final Pattern dateTimePattern = Pattern.compile("^\\d+(-\\d+){2}+T(\\d+:){2}\\d+.\\d+(Z|([+-](\\d+:\\d+)))?$");
|
||||
private static final DateFormatType dateTimeNoMillisFormatter = DateFormatType.XEP_0082_DATETIME_PROFILE;
|
||||
private static final Pattern dateTimeNoMillisPattern = Pattern.compile("^\\d+(-\\d+){2}+T(\\d+:){2}\\d+(Z|([+-](\\d+:\\d+)))?$");
|
||||
|
||||
private static final DateFormat xep0091Formatter = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss");
|
||||
private static final DateFormat xep0091Date6DigitFormatter = new SimpleDateFormat(
|
||||
"yyyyMd'T'HH:mm:ss");
|
||||
private static final DateFormat xep0091Date7Digit1MonthFormatter = new SimpleDateFormat(
|
||||
"yyyyMdd'T'HH:mm:ss");
|
||||
private static final DateFormat xep0091Date7Digit2MonthFormatter = new SimpleDateFormat(
|
||||
"yyyyMMd'T'HH:mm:ss");
|
||||
private static final Pattern xep0091Pattern = Pattern.compile("^\\d+T\\d+:\\d+:\\d+$");
|
||||
|
||||
public static enum DateFormatType {
|
||||
// @formatter:off
|
||||
XEP_0082_DATE_PROFILE("yyyy-MM-dd"),
|
||||
XEP_0082_DATETIME_PROFILE("yyyy-MM-dd'T'HH:mm:ssZ"),
|
||||
XEP_0082_DATETIME_MILLIS_PROFILE("yyyy-MM-dd'T'HH:mm:ss.SSSZ"),
|
||||
XEP_0082_TIME_PROFILE("hh:mm:ss"),
|
||||
XEP_0082_TIME_ZONE_PROFILE("hh:mm:ssZ"),
|
||||
XEP_0082_TIME_MILLIS_PROFILE("hh:mm:ss.SSS"),
|
||||
XEP_0082_TIME_MILLIS_ZONE_PROFILE("hh:mm:ss.SSSZ"),
|
||||
XEP_0091_DATETIME("yyyyMMdd'T'HH:mm:ss");
|
||||
// @formatter:on
|
||||
|
||||
private final String FORMAT_STRING;
|
||||
private final DateFormat FORMATTER;
|
||||
private final boolean CONVERT_TIMEZONE;
|
||||
|
||||
private DateFormatType(String dateFormat) {
|
||||
FORMAT_STRING = dateFormat;
|
||||
FORMATTER = new SimpleDateFormat(FORMAT_STRING);
|
||||
FORMATTER.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
CONVERT_TIMEZONE = dateFormat.charAt(dateFormat.length() - 1) == 'Z';
|
||||
}
|
||||
|
||||
public String format(Date date) {
|
||||
String res;
|
||||
synchronized(FORMATTER) {
|
||||
res = FORMATTER.format(date);
|
||||
}
|
||||
if (CONVERT_TIMEZONE) {
|
||||
res = convertRfc822TimezoneToXep82(res);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public Date parse(String dateString) throws ParseException {
|
||||
if (CONVERT_TIMEZONE) {
|
||||
dateString = convertXep82TimezoneToRfc822(dateString);
|
||||
}
|
||||
synchronized(FORMATTER) {
|
||||
return FORMATTER.parse(dateString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final List<PatternCouplings> couplings = new ArrayList<PatternCouplings>();
|
||||
|
||||
static {
|
||||
TimeZone utc = TimeZone.getTimeZone("UTC");
|
||||
|
||||
xep0091Formatter.setTimeZone(utc);
|
||||
xep0091Date6DigitFormatter.setTimeZone(utc);
|
||||
xep0091Date7Digit1MonthFormatter.setTimeZone(utc);
|
||||
xep0091Date7Digit1MonthFormatter.setLenient(false);
|
||||
xep0091Date7Digit2MonthFormatter.setTimeZone(utc);
|
||||
xep0091Date7Digit2MonthFormatter.setLenient(false);
|
||||
|
||||
couplings.add(new PatternCouplings(datePattern, dateFormatter));
|
||||
couplings.add(new PatternCouplings(dateTimePattern, dateTimeFormatter));
|
||||
couplings.add(new PatternCouplings(dateTimeNoMillisPattern, dateTimeNoMillisFormatter));
|
||||
couplings.add(new PatternCouplings(timePattern, timeFormatter));
|
||||
couplings.add(new PatternCouplings(timeNoZonePattern, timeNoZoneFormatter));
|
||||
couplings.add(new PatternCouplings(timeNoMillisPattern, timeNoMillisFormatter));
|
||||
couplings.add(new PatternCouplings(timeNoMillisNoZonePattern, timeNoMillisNoZoneFormatter));
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the given date string in the <a
|
||||
* href="http://xmpp.org/extensions/xep-0082.html">XEP-0082 - XMPP Date and Time Profiles</a>.
|
||||
*
|
||||
* @param dateString the date string to parse
|
||||
* @return the parsed Date
|
||||
* @throws ParseException if the specified string cannot be parsed
|
||||
* @deprecated Use {@link #parseDate(String)} instead.
|
||||
*/
|
||||
public static Date parseXEP0082Date(String dateString) throws ParseException {
|
||||
return parseDate(dateString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the given date string in either of the three profiles of <a
|
||||
* href="http://xmpp.org/extensions/xep-0082.html">XEP-0082 - XMPP Date and Time Profiles</a> or
|
||||
* <a href="http://xmpp.org/extensions/xep-0091.html">XEP-0091 - Legacy Delayed Delivery</a>
|
||||
* format.
|
||||
* <p>
|
||||
* This method uses internal date formatters and is thus threadsafe.
|
||||
*
|
||||
* @param dateString the date string to parse
|
||||
* @return the parsed Date
|
||||
* @throws ParseException if the specified string cannot be parsed
|
||||
*/
|
||||
public static Date parseDate(String dateString) throws ParseException {
|
||||
Matcher matcher = xep0091Pattern.matcher(dateString);
|
||||
|
||||
/*
|
||||
* if date is in XEP-0091 format handle ambiguous dates missing the leading zero in month
|
||||
* and day
|
||||
*/
|
||||
if (matcher.matches()) {
|
||||
int length = dateString.split("T")[0].length();
|
||||
|
||||
if (length < 8) {
|
||||
Date date = handleDateWithMissingLeadingZeros(dateString, length);
|
||||
|
||||
if (date != null)
|
||||
return date;
|
||||
}
|
||||
else {
|
||||
synchronized (xep0091Formatter) {
|
||||
return xep0091Formatter.parse(dateString);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (PatternCouplings coupling : couplings) {
|
||||
matcher = coupling.pattern.matcher(dateString);
|
||||
|
||||
if (matcher.matches()) {
|
||||
return coupling.formatter.parse(dateString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* We assume it is the XEP-0082 DateTime profile with no milliseconds at this point. If it
|
||||
* isn't, is is just not parseable, then we attempt to parse it regardless and let it throw
|
||||
* the ParseException.
|
||||
*/
|
||||
synchronized (dateTimeNoMillisFormatter) {
|
||||
return dateTimeNoMillisFormatter.parse(dateString);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a Date into a XEP-0082 - XMPP Date and Time Profiles string.
|
||||
*
|
||||
* @param date the time value to be formatted into a time string
|
||||
* @return the formatted time string in XEP-0082 format
|
||||
*/
|
||||
public static String formatXEP0082Date(Date date) {
|
||||
synchronized (dateTimeFormatter) {
|
||||
return dateTimeFormatter.format(date);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a XEP-0082 date String's time zone definition into a RFC822 time zone definition.
|
||||
* The major difference is that XEP-0082 uses a smicolon between hours and minutes and RFC822
|
||||
* does not.
|
||||
*
|
||||
* @param dateString
|
||||
* @return the String with converted timezone
|
||||
*/
|
||||
public static String convertXep82TimezoneToRfc822(String dateString) {
|
||||
if (dateString.charAt(dateString.length() - 1) == 'Z') {
|
||||
return dateString.replace("Z", "+0000");
|
||||
}
|
||||
else {
|
||||
// If the time zone wasn't specified with 'Z', then it's in
|
||||
// ISO8601 format (i.e. '(+|-)HH:mm')
|
||||
// RFC822 needs a similar format just without the colon (i.e.
|
||||
// '(+|-)HHmm)'), so remove it
|
||||
return dateString.replaceAll("([\\+\\-]\\d\\d):(\\d\\d)", "$1$2");
|
||||
}
|
||||
}
|
||||
|
||||
public static String convertRfc822TimezoneToXep82(String dateString) {
|
||||
int length = dateString.length();
|
||||
String res = dateString.substring(0, length -2);
|
||||
res += ':';
|
||||
res += dateString.substring(length - 2, length);
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a time zone to the String format as specified in XEP-0082
|
||||
*
|
||||
* @param timeZone
|
||||
* @return the String representation of the TimeZone
|
||||
*/
|
||||
public static String asString(TimeZone timeZone) {
|
||||
int rawOffset = timeZone.getRawOffset();
|
||||
int hours = rawOffset / (1000*60*60);
|
||||
int minutes = Math.abs((rawOffset / (1000*60)) - (hours * 60));
|
||||
return String.format("%+d:%02d", hours, minutes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the given date string in different ways and returns the date that lies in the past
|
||||
* and/or is nearest to the current date-time.
|
||||
*
|
||||
* @param stampString date in string representation
|
||||
* @param dateLength
|
||||
* @param noFuture
|
||||
* @return the parsed date
|
||||
* @throws ParseException The date string was of an unknown format
|
||||
*/
|
||||
private static Date handleDateWithMissingLeadingZeros(String stampString, int dateLength)
|
||||
throws ParseException {
|
||||
if (dateLength == 6) {
|
||||
synchronized (xep0091Date6DigitFormatter) {
|
||||
return xep0091Date6DigitFormatter.parse(stampString);
|
||||
}
|
||||
}
|
||||
Calendar now = Calendar.getInstance();
|
||||
|
||||
Calendar oneDigitMonth = parseXEP91Date(stampString, xep0091Date7Digit1MonthFormatter);
|
||||
Calendar twoDigitMonth = parseXEP91Date(stampString, xep0091Date7Digit2MonthFormatter);
|
||||
|
||||
List<Calendar> dates = filterDatesBefore(now, oneDigitMonth, twoDigitMonth);
|
||||
|
||||
if (!dates.isEmpty()) {
|
||||
return determineNearestDate(now, dates).getTime();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Calendar parseXEP91Date(String stampString, DateFormat dateFormat) {
|
||||
try {
|
||||
synchronized (dateFormat) {
|
||||
dateFormat.parse(stampString);
|
||||
return dateFormat.getCalendar();
|
||||
}
|
||||
}
|
||||
catch (ParseException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static List<Calendar> filterDatesBefore(Calendar now, Calendar... dates) {
|
||||
List<Calendar> result = new ArrayList<Calendar>();
|
||||
|
||||
for (Calendar calendar : dates) {
|
||||
if (calendar != null && calendar.before(now)) {
|
||||
result.add(calendar);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Calendar determineNearestDate(final Calendar now, List<Calendar> dates) {
|
||||
|
||||
Collections.sort(dates, new Comparator<Calendar>() {
|
||||
|
||||
public int compare(Calendar o1, Calendar o2) {
|
||||
Long diff1 = new Long(now.getTimeInMillis() - o1.getTimeInMillis());
|
||||
Long diff2 = new Long(now.getTimeInMillis() - o2.getTimeInMillis());
|
||||
return diff1.compareTo(diff2);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return dates.get(0);
|
||||
}
|
||||
|
||||
private static class PatternCouplings {
|
||||
final Pattern pattern;
|
||||
final DateFormatType formatter;
|
||||
|
||||
public PatternCouplings(Pattern datePattern, DateFormatType dateFormat) {
|
||||
pattern = datePattern;
|
||||
formatter = dateFormat;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -199,20 +199,4 @@ public class StringUtilsTest {
|
|||
result = StringUtils.randomString(128);
|
||||
assertTrue(result.length() == 128);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParsing() {
|
||||
String error = "Error parsing node name";
|
||||
assertEquals(error, "", StringUtils.parseName("yahoo.myjabber.net"));
|
||||
assertEquals(error, "", StringUtils.parseName("yahoo.myjabber.net/registred"));
|
||||
assertEquals(error, "user", StringUtils.parseName("user@yahoo.myjabber.net/registred"));
|
||||
assertEquals(error, "user", StringUtils.parseName("user@yahoo.myjabber.net"));
|
||||
|
||||
error = "Error parsing server name";
|
||||
String result = "yahoo.myjabber.net";
|
||||
assertEquals(error, result, StringUtils.parseServer("yahoo.myjabber.net"));
|
||||
assertEquals(error, result, StringUtils.parseServer("yahoo.myjabber.net/registred"));
|
||||
assertEquals(error, result, StringUtils.parseServer("user@yahoo.myjabber.net/registred"));
|
||||
assertEquals(error, result, StringUtils.parseServer("user@yahoo.myjabber.net"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,232 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jivesoftware.smack.util;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class XmppDateTimeTest {
|
||||
@Test
|
||||
public void parseXep0082Date() throws Exception {
|
||||
Date date = XmppDateTime.parseDate("1971-07-21");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
assertEquals(1971, cal.get(Calendar.YEAR));
|
||||
assertEquals(6, cal.get(Calendar.MONTH));
|
||||
assertEquals(21, cal.get(Calendar.DAY_OF_MONTH));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseXep0082Time() throws Exception {
|
||||
Date date = XmppDateTime.parseDate("02:56:15");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
assertEquals(2, cal.get(Calendar.HOUR_OF_DAY));
|
||||
assertEquals(56, cal.get(Calendar.MINUTE));
|
||||
assertEquals(15, cal.get(Calendar.SECOND));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseXep0082TimeUTC() throws Exception {
|
||||
Date date = XmppDateTime.parseDate("02:56:15Z");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
assertEquals(2, cal.get(Calendar.HOUR_OF_DAY));
|
||||
assertEquals(56, cal.get(Calendar.MINUTE));
|
||||
assertEquals(15, cal.get(Calendar.SECOND));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseXep0082TimeWithZone() throws Exception {
|
||||
Date date = XmppDateTime.parseDate("04:40:15+02:30");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
assertEquals(2, cal.get(Calendar.HOUR_OF_DAY));
|
||||
assertEquals(10, cal.get(Calendar.MINUTE));
|
||||
assertEquals(15, cal.get(Calendar.SECOND));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseXep0082TimeWithMillis() throws Exception {
|
||||
Date date = XmppDateTime.parseDate("02:56:15.123");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
assertEquals(2, cal.get(Calendar.HOUR_OF_DAY));
|
||||
assertEquals(56, cal.get(Calendar.MINUTE));
|
||||
assertEquals(15, cal.get(Calendar.SECOND));
|
||||
assertEquals(123, cal.get(Calendar.MILLISECOND));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseXep0082TimeWithMillisUTC() throws Exception {
|
||||
Date date = XmppDateTime.parseDate("02:56:15.123Z");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
assertEquals(2, cal.get(Calendar.HOUR_OF_DAY));
|
||||
assertEquals(56, cal.get(Calendar.MINUTE));
|
||||
assertEquals(15, cal.get(Calendar.SECOND));
|
||||
assertEquals(123, cal.get(Calendar.MILLISECOND));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseXep0082TimeWithMillisZone() throws Exception {
|
||||
Date date = XmppDateTime.parseDate("02:56:15.123+01:00");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
assertEquals(1, cal.get(Calendar.HOUR_OF_DAY));
|
||||
assertEquals(56, cal.get(Calendar.MINUTE));
|
||||
assertEquals(15, cal.get(Calendar.SECOND));
|
||||
assertEquals(123, cal.get(Calendar.MILLISECOND));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseXep0082DateTimeUTC() throws Exception {
|
||||
Date date = XmppDateTime.parseDate("1971-07-21T02:56:15Z");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
assertEquals(1971, cal.get(Calendar.YEAR));
|
||||
assertEquals(6, cal.get(Calendar.MONTH));
|
||||
assertEquals(21, cal.get(Calendar.DAY_OF_MONTH));
|
||||
assertEquals(2, cal.get(Calendar.HOUR_OF_DAY));
|
||||
assertEquals(56, cal.get(Calendar.MINUTE));
|
||||
assertEquals(15, cal.get(Calendar.SECOND));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseXep0082DateTimeZone() throws Exception {
|
||||
Date date = XmppDateTime.parseDate("1971-07-21T02:56:15-01:00");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
assertEquals(1971, cal.get(Calendar.YEAR));
|
||||
assertEquals(6, cal.get(Calendar.MONTH));
|
||||
assertEquals(21, cal.get(Calendar.DAY_OF_MONTH));
|
||||
assertEquals(3, cal.get(Calendar.HOUR_OF_DAY));
|
||||
assertEquals(56, cal.get(Calendar.MINUTE));
|
||||
assertEquals(15, cal.get(Calendar.SECOND));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseXep0082DateTimeWithMillisUTC() throws Exception {
|
||||
Date date = XmppDateTime.parseDate("1971-07-21T02:56:15.123Z");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
assertEquals(1971, cal.get(Calendar.YEAR));
|
||||
assertEquals(6, cal.get(Calendar.MONTH));
|
||||
assertEquals(21, cal.get(Calendar.DAY_OF_MONTH));
|
||||
assertEquals(2, cal.get(Calendar.HOUR_OF_DAY));
|
||||
assertEquals(56, cal.get(Calendar.MINUTE));
|
||||
assertEquals(15, cal.get(Calendar.SECOND));
|
||||
assertEquals(123, cal.get(Calendar.MILLISECOND));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseXep0082DateTimeWithMillisZone() throws Exception {
|
||||
Date date = XmppDateTime.parseDate("1971-07-21T02:56:15.123-01:00");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
assertEquals(1971, cal.get(Calendar.YEAR));
|
||||
assertEquals(6, cal.get(Calendar.MONTH));
|
||||
assertEquals(21, cal.get(Calendar.DAY_OF_MONTH));
|
||||
assertEquals(3, cal.get(Calendar.HOUR_OF_DAY));
|
||||
assertEquals(56, cal.get(Calendar.MINUTE));
|
||||
assertEquals(15, cal.get(Calendar.SECOND));
|
||||
assertEquals(123, cal.get(Calendar.MILLISECOND));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseXep0091() throws Exception {
|
||||
Date date = XmppDateTime.parseDate("20020910T23:08:25");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
assertEquals(2002, cal.get(Calendar.YEAR));
|
||||
assertEquals(8, cal.get(Calendar.MONTH));
|
||||
assertEquals(10, cal.get(Calendar.DAY_OF_MONTH));
|
||||
assertEquals(23, cal.get(Calendar.HOUR_OF_DAY));
|
||||
assertEquals(8, cal.get(Calendar.MINUTE));
|
||||
assertEquals(25, cal.get(Calendar.SECOND));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseXep0091NoLeading0() throws Exception {
|
||||
Date date = XmppDateTime.parseDate("200291T23:08:25");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
assertEquals(2002, cal.get(Calendar.YEAR));
|
||||
assertEquals(8, cal.get(Calendar.MONTH));
|
||||
assertEquals(1, cal.get(Calendar.DAY_OF_MONTH));
|
||||
assertEquals(23, cal.get(Calendar.HOUR_OF_DAY));
|
||||
assertEquals(8, cal.get(Calendar.MINUTE));
|
||||
assertEquals(25, cal.get(Calendar.SECOND));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseXep0091AmbiguousMonthDay() throws Exception {
|
||||
Date date = XmppDateTime.parseDate("2002101T23:08:25");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
assertEquals(2002, cal.get(Calendar.YEAR));
|
||||
assertEquals(9, cal.get(Calendar.MONTH));
|
||||
assertEquals(1, cal.get(Calendar.DAY_OF_MONTH));
|
||||
assertEquals(23, cal.get(Calendar.HOUR_OF_DAY));
|
||||
assertEquals(8, cal.get(Calendar.MINUTE));
|
||||
assertEquals(25, cal.get(Calendar.SECOND));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseXep0091SingleDigitMonth() throws Exception {
|
||||
Date date = XmppDateTime.parseDate("2002130T23:08:25");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
assertEquals(2002, cal.get(Calendar.YEAR));
|
||||
assertEquals(0, cal.get(Calendar.MONTH));
|
||||
assertEquals(30, cal.get(Calendar.DAY_OF_MONTH));
|
||||
assertEquals(23, cal.get(Calendar.HOUR_OF_DAY));
|
||||
assertEquals(8, cal.get(Calendar.MINUTE));
|
||||
assertEquals(25, cal.get(Calendar.SECOND));
|
||||
}
|
||||
|
||||
@Test(expected = ParseException.class)
|
||||
public void parseNoMonthDay() throws Exception {
|
||||
XmppDateTime.parseDate("2002T23:08:25");
|
||||
}
|
||||
|
||||
@Test(expected = ParseException.class)
|
||||
public void parseNoYear() throws Exception {
|
||||
XmppDateTime.parseDate("130T23:08:25");
|
||||
}
|
||||
}
|
|
@ -26,11 +26,11 @@ import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
|||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.util.Cache;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smackx.address.packet.MultipleAddresses;
|
||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverItems;
|
||||
import org.jxmpp.util.XmppStringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
@ -175,7 +175,7 @@ public class MultipleRecipientManager {
|
|||
// Remove the sender from the TO/CC list (try with bare JID too)
|
||||
String from = connection.getUser();
|
||||
if (!to.remove(from) && !cc.remove(from)) {
|
||||
String bareJID = StringUtils.parseBareAddress(from);
|
||||
String bareJID = XmppStringUtils.parseBareAddress(from);
|
||||
to.remove(bareJID);
|
||||
cc.remove(bareJID);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.jivesoftware.smack.SmackException.NoResponseException;
|
|||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.util.XmppDateTime;
|
||||
import org.jxmpp.util.XmppDateTime;
|
||||
import org.jivesoftware.smackx.amp.packet.AMPExtension;
|
||||
|
||||
import java.util.Date;
|
||||
|
|
|
@ -18,7 +18,7 @@ package org.jivesoftware.smackx.delay.packet;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import org.jivesoftware.smack.util.XmppDateTime;
|
||||
import org.jxmpp.util.XmppDateTime;
|
||||
|
||||
/**
|
||||
* A decorator for the {@link DelayInformation} class to transparently support
|
||||
|
|
|
@ -21,7 +21,7 @@ import java.util.Date;
|
|||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.util.XmppDateTime;
|
||||
import org.jxmpp.util.XmppDateTime;
|
||||
import org.jivesoftware.smackx.delay.packet.DelayInformation;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@ import org.jivesoftware.smack.filter.PacketTypeFilter;
|
|||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smackx.si.packet.StreamInitiation;
|
||||
import org.jxmpp.util.XmppStringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -136,7 +136,7 @@ public class FileTransferManager {
|
|||
// We need to create outgoing file transfers with a full JID since this method will later
|
||||
// use XEP-0095 to negotiate the stream. This is done with IQ stanzas that need to be addressed to a full JID
|
||||
// in order to reach an client entity.
|
||||
else if (!StringUtils.isFullJID(userID)) {
|
||||
else if (!XmppStringUtils.isFullJID(userID)) {
|
||||
throw new IllegalArgumentException("The provided user id was not a full JID (i.e. with resource part)");
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.jivesoftware.smackx.muc;
|
|||
import org.jivesoftware.smackx.muc.packet.MUCAdmin;
|
||||
import org.jivesoftware.smackx.muc.packet.MUCUser;
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jxmpp.util.XmppStringUtils;
|
||||
|
||||
/**
|
||||
* Represents the information about an occupant in a given room. The information will always have
|
||||
|
@ -53,7 +53,7 @@ public class Occupant {
|
|||
this.affiliation = item.getAffiliation();
|
||||
this.role = item.getRole();
|
||||
// Get the nickname from the FROM attribute of the presence
|
||||
this.nick = StringUtils.parseResource(presence.getFrom());
|
||||
this.nick = XmppStringUtils.parseResource(presence.getFrom());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
|
|||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jxmpp.util.XmppStringUtils;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Locale;
|
||||
|
@ -151,7 +151,7 @@ class RoomListenerMultiplexor extends AbstractConnectionListener {
|
|||
if (from == null) {
|
||||
return false;
|
||||
}
|
||||
return roomAddressTable.containsKey(StringUtils.parseBareAddress(from).toLowerCase(Locale.US));
|
||||
return roomAddressTable.containsKey(XmppStringUtils.parseBareAddress(from).toLowerCase(Locale.US));
|
||||
}
|
||||
|
||||
public void addRoom(String address) {
|
||||
|
@ -192,7 +192,7 @@ class RoomListenerMultiplexor extends AbstractConnectionListener {
|
|||
}
|
||||
|
||||
PacketMultiplexListener listener =
|
||||
roomListenersByAddress.get(StringUtils.parseBareAddress(from).toLowerCase(Locale.US));
|
||||
roomListenersByAddress.get(XmppStringUtils.parseBareAddress(from).toLowerCase(Locale.US));
|
||||
|
||||
if (listener != null) {
|
||||
listener.processPacket(p);
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
import java.util.UnknownFormatConversionException;
|
||||
|
||||
import org.jivesoftware.smack.util.XmppDateTime;
|
||||
import org.jxmpp.util.XmppDateTime;
|
||||
import org.jivesoftware.smackx.xdata.Form;
|
||||
import org.jivesoftware.smackx.xdata.FormField;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
|
|
|
@ -21,7 +21,7 @@ import java.util.Date;
|
|||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smack.util.XmppDateTime;
|
||||
import org.jxmpp.util.XmppDateTime;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.logging.Logger;
|
|||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.XmppDateTime;
|
||||
import org.jxmpp.util.XmppDateTime;
|
||||
import org.jivesoftware.smackx.si.packet.StreamInitiation;
|
||||
import org.jivesoftware.smackx.si.packet.StreamInitiation.File;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
|
|
|
@ -18,7 +18,7 @@ package org.jivesoftware.smackx.time.packet;
|
|||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.util.XmppDateTime;
|
||||
import org.jxmpp.util.XmppDateTime;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
|
|
@ -29,7 +29,7 @@ import java.util.TimeZone;
|
|||
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.util.XmppDateTime;
|
||||
import org.jxmpp.util.XmppDateTime;
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.jivesoftware.smackx.delay.packet.DelayInfo;
|
||||
import org.jivesoftware.smackx.delay.packet.DelayInformation;
|
||||
|
|
|
@ -33,7 +33,6 @@ import org.jivesoftware.smack.packet.IQ;
|
|||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smack.provider.ProviderManager;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
import org.jivesoftware.smackx.jingle.listeners.CreatedJingleSessionListener;
|
||||
import org.jivesoftware.smackx.jingle.listeners.JingleListener;
|
||||
|
@ -46,6 +45,7 @@ import org.jivesoftware.smackx.jingle.nat.TransportCandidate;
|
|||
import org.jivesoftware.smackx.jingle.nat.TransportResolver;
|
||||
import org.jivesoftware.smackx.jingle.packet.Jingle;
|
||||
import org.jivesoftware.smackx.jingle.provider.JingleProvider;
|
||||
import org.jxmpp.util.XmppStringUtils;
|
||||
|
||||
/**
|
||||
* Jingle is a session establishment protocol defined in (XEP-0166).
|
||||
|
@ -518,8 +518,7 @@ public class JingleManager implements JingleSessionListener {
|
|||
*/
|
||||
public JingleSession createOutgoingJingleSession(String responder) throws XMPPException {
|
||||
|
||||
if (responder == null || StringUtils.parseName(responder).length() <= 0 || StringUtils.parseServer(responder).length() <= 0
|
||||
|| StringUtils.parseResource(responder).length() <= 0) {
|
||||
if (XmppStringUtils.isFullJID(responder)) {
|
||||
throw new IllegalArgumentException("The provided user id was not fully qualified");
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.jivesoftware.smack.filter.PacketFilter;
|
|||
import org.jivesoftware.smack.filter.PacketTypeFilter;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jxmpp.util.XmppStringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -249,7 +249,7 @@ public class AgentRoster {
|
|||
private String getPresenceMapKey(String user) {
|
||||
String key = user;
|
||||
if (!contains(user)) {
|
||||
key = StringUtils.parseBareAddress(user).toLowerCase(Locale.US);
|
||||
key = XmppStringUtils.parseBareAddress(user).toLowerCase(Locale.US);
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
@ -317,13 +317,13 @@ public class AgentRoster {
|
|||
}
|
||||
// Add the new presence, using the resources as a key.
|
||||
synchronized (userPresences) {
|
||||
userPresences.put(StringUtils.parseResource(from), presence);
|
||||
userPresences.put(XmppStringUtils.parseResource(from), presence);
|
||||
}
|
||||
// Fire an event.
|
||||
synchronized (entries) {
|
||||
for (Iterator<String> i = entries.iterator(); i.hasNext();) {
|
||||
String entry = i.next();
|
||||
if (entry.toLowerCase(Locale.US).equals(StringUtils.parseBareAddress(key).toLowerCase())) {
|
||||
if (entry.toLowerCase(Locale.US).equals(XmppStringUtils.parseBareAddress(key).toLowerCase())) {
|
||||
fireEvent(EVENT_PRESENCE_CHANGED, packet);
|
||||
}
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ public class AgentRoster {
|
|||
if (presenceMap.get(key) != null) {
|
||||
Map<String,Presence> userPresences = presenceMap.get(key);
|
||||
synchronized (userPresences) {
|
||||
userPresences.remove(StringUtils.parseResource(from));
|
||||
userPresences.remove(XmppStringUtils.parseResource(from));
|
||||
}
|
||||
if (userPresences.isEmpty()) {
|
||||
presenceMap.remove(key);
|
||||
|
@ -344,7 +344,7 @@ public class AgentRoster {
|
|||
synchronized (entries) {
|
||||
for (Iterator<String> i = entries.iterator(); i.hasNext();) {
|
||||
String entry = (String)i.next();
|
||||
if (entry.toLowerCase(Locale.US).equals(StringUtils.parseBareAddress(key).toLowerCase())) {
|
||||
if (entry.toLowerCase(Locale.US).equals(XmppStringUtils.parseBareAddress(key).toLowerCase())) {
|
||||
fireEvent(EVENT_PRESENCE_CHANGED, packet);
|
||||
}
|
||||
}
|
||||
|
@ -368,8 +368,8 @@ public class AgentRoster {
|
|||
|
||||
// Removing the user from the roster, so remove any presence information
|
||||
// about them.
|
||||
String key = StringUtils.parseName(StringUtils.parseName(agentJID) + "@" +
|
||||
StringUtils.parseServer(agentJID));
|
||||
String key = XmppStringUtils.parseLocalpart(XmppStringUtils.parseLocalpart(agentJID) + "@" +
|
||||
XmppStringUtils.parseDomain(agentJID));
|
||||
presenceMap.remove(key);
|
||||
// Fire event for roster listeners.
|
||||
fireEvent(EVENT_AGENT_REMOVED, agentJID);
|
||||
|
|
|
@ -39,7 +39,7 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
|
|||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.filter.*;
|
||||
import org.jivesoftware.smack.packet.*;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jxmpp.util.XmppStringUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
@ -478,7 +478,7 @@ public class AgentSession {
|
|||
* @throws SmackException
|
||||
*/
|
||||
public Form getTranscriptSearchForm() throws XMPPException, SmackException {
|
||||
return transcriptSearchManager.getSearchForm(StringUtils.parseServer(workgroupJID));
|
||||
return transcriptSearchManager.getSearchForm(XmppStringUtils.parseDomain(workgroupJID));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -492,7 +492,7 @@ public class AgentSession {
|
|||
* @throws XMPPException
|
||||
*/
|
||||
public ReportedData searchTranscripts(Form completedForm) throws XMPPException, SmackException {
|
||||
return transcriptSearchManager.submitSearch(StringUtils.parseServer(workgroupJID),
|
||||
return transcriptSearchManager.submitSearch(XmppStringUtils.parseDomain(workgroupJID),
|
||||
completedForm);
|
||||
}
|
||||
|
||||
|
@ -686,7 +686,7 @@ public class AgentSession {
|
|||
// check for different packet extensions to see what type of presence
|
||||
// packet it is.
|
||||
|
||||
String queueName = StringUtils.parseResource(presence.getFrom());
|
||||
String queueName = XmppStringUtils.parseResource(presence.getFrom());
|
||||
WorkgroupQueue queue = queues.get(queueName);
|
||||
// If there isn't already an entry for the queue, create a new one.
|
||||
if (queue == null) {
|
||||
|
|
|
@ -34,11 +34,11 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
|
|||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.filter.*;
|
||||
import org.jivesoftware.smack.packet.*;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||
import org.jivesoftware.smackx.muc.MultiUserChat;
|
||||
import org.jivesoftware.smackx.muc.packet.MUCUser;
|
||||
import org.jxmpp.util.XmppStringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
@ -664,7 +664,7 @@ public class Workgroup {
|
|||
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||
|
||||
try {
|
||||
String workgroupService = StringUtils.parseServer(workgroupJID);
|
||||
String workgroupService = XmppStringUtils.parseDomain(workgroupJID);
|
||||
DiscoverInfo infoResult = discoManager.discoverInfo(workgroupService);
|
||||
return infoResult.containsFeature("jive:email:provider");
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@ import org.jivesoftware.smack.sasl.SASLMechanism.SASLFailure;
|
|||
import org.jivesoftware.smack.sasl.SASLMechanism.Success;
|
||||
import org.jivesoftware.smack.util.ArrayBlockingQueueWithShutdown;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smack.util.TLSUtils;
|
||||
import org.jivesoftware.smack.util.dns.HostAddress;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
@ -280,7 +279,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
|||
if (response != null) {
|
||||
this.user = response;
|
||||
// Update the serviceName with the one returned by the server
|
||||
setServiceName(StringUtils.parseServer(response));
|
||||
setServiceName(response);
|
||||
}
|
||||
else {
|
||||
this.user = username + "@" + getServiceName();
|
||||
|
@ -331,7 +330,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
|||
// Set the user value.
|
||||
this.user = response;
|
||||
// Update the serviceName with the one returned by the server
|
||||
setServiceName(StringUtils.parseServer(response));
|
||||
setServiceName(response);
|
||||
|
||||
// If compression is enabled then request the server to use stream compression
|
||||
if (config.isCompressionEnabled()) {
|
||||
|
|
Loading…
Reference in a new issue