Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2008-11-06 18:34:50 -0500
committerslewis2008-11-06 18:34:50 -0500
commitbf18b9e3459bc398c768b2a883977dda48e7ba81 (patch)
tree7d0315e3b4a4aa0e0129fceb7fdf1649e253689c /providers/bundles/org.eclipse.ecf.provider.xmpp
parent747e6179cbc1c343ab974394053ebad8ad22598c (diff)
downloadorg.eclipse.ecf-bf18b9e3459bc398c768b2a883977dda48e7ba81.tar.gz
org.eclipse.ecf-bf18b9e3459bc398c768b2a883977dda48e7ba81.tar.xz
org.eclipse.ecf-bf18b9e3459bc398c768b2a883977dda48e7ba81.zip
Fix for use of uri for internal representation of XMPPID
Diffstat (limited to 'providers/bundles/org.eclipse.ecf.provider.xmpp')
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/smack/ECFConnection.java94
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPID.java17
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPSID.java2
3 files changed, 58 insertions, 55 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/smack/ECFConnection.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/smack/ECFConnection.java
index ba1cc5fd9..20e9292e7 100644
--- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/smack/ECFConnection.java
+++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/internal/provider/xmpp/smack/ECFConnection.java
@@ -51,7 +51,9 @@ public class ECFConnection implements ISynchAsynchConnection {
public static final boolean DEBUG = Boolean.getBoolean("smack.debug");
protected static final String STRING_ENCODING = "UTF-8";
- public static final String OBJECT_PROPERTY_NAME = ECFConnection.class.getName() + ".object";
+ public static final String OBJECT_PROPERTY_NAME = ECFConnection.class
+ .getName()
+ + ".object";
protected static final int XMPP_DEFAULT_PORT = 5222;
protected static final int XMPPS_DEFAULT_PORT = 5223;
@@ -95,7 +97,9 @@ public class ECFConnection implements ISynchAsynchConnection {
return properties;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/
public Object getAdapter(Class adapter) {
@@ -103,15 +107,18 @@ public class ECFConnection implements ISynchAsynchConnection {
return null;
if (adapter.isInstance(this))
return this;
- final IAdapterManager adapterManager = XmppPlugin.getDefault().getAdapterManager();
- return (adapterManager == null) ? null : adapterManager.loadAdapter(this, adapter.getName());
+ final IAdapterManager adapterManager = XmppPlugin.getDefault()
+ .getAdapterManager();
+ return (adapterManager == null) ? null : adapterManager.loadAdapter(
+ this, adapter.getName());
}
public XMPPConnection getXMPPConnection() {
return connection;
}
- public ECFConnection(boolean google, Namespace ns, IAsynchEventHandler h, boolean secure) {
+ public ECFConnection(boolean google, Namespace ns, IAsynchEventHandler h,
+ boolean secure) {
this.handler = h;
this.namespace = ns;
this.google = google;
@@ -144,7 +151,8 @@ public class ECFConnection implements ISynchAsynchConnection {
return jabberID;
}
- public synchronized Object connect(ID remote, Object data, int timeout) throws ECFException {
+ public synchronized Object connect(ID remote, Object data, int timeout)
+ throws ECFException {
if (connection != null)
throw new ECFException("already connected");
if (timeout > 0)
@@ -156,35 +164,22 @@ public class ECFConnection implements ISynchAsynchConnection {
serverName = jabberURI.getHostname();
serverPort = jabberURI.getPort();
serverResource = jabberURI.getResourceName();
- if (serverResource == null || serverResource.equals(XMPPID.PATH_DELIMITER)) {
+ if (serverResource == null
+ || serverResource.equals(XMPPID.PATH_DELIMITER)) {
serverResource = getClientIdentifier();
jabberURI.setResourceName(serverResource);
}
try {
- if (google) {
- if (secure) {
- if (serverPort == -1) {
- serverPort = XMPPS_DEFAULT_PORT;
- }
- connection = new SSLXMPPConnection(GOOGLE_TALK_HOST, serverPort, jabberURI.getHostname());
- } else {
- if (serverPort == -1) {
- serverPort = XMPP_DEFAULT_PORT;
- }
- connection = new XMPPConnection(GOOGLE_TALK_HOST, serverPort, jabberURI.getHostname());
- }
- } else if (serverPort == -1) {
- if (secure) {
- connection = new SSLXMPPConnection(serverName);
- } else {
- connection = new XMPPConnection(serverName);
- }
+ if (google)
+ serverName = GOOGLE_TALK_HOST;
+ if (secure) {
+ serverPort = (serverPort < 0)?XMPPS_DEFAULT_PORT:serverPort;
+ connection = new SSLXMPPConnection(serverName,
+ serverPort, jabberURI.getHostname());
} else {
- if (secure) {
- connection = new SSLXMPPConnection(serverName, serverPort);
- } else {
- connection = new XMPPConnection(serverName, serverPort);
- }
+ serverPort = (serverPort < 0)?XMPP_DEFAULT_PORT:serverPort;
+ connection = new XMPPConnection(GOOGLE_TALK_HOST, serverPort,
+ jabberURI.getHostname());
}
connection.addPacketListener(packetListener, null);
connection.addConnectionListener(connectionListener);
@@ -193,7 +188,8 @@ public class ECFConnection implements ISynchAsynchConnection {
isConnected = true;
} catch (final XMPPException e) {
if (e.getMessage().equals("(401)"))
- throw new ContainerAuthenticationException("Password incorrect", e);
+ throw new ContainerAuthenticationException(
+ "Password incorrect", e);
throw new ContainerConnectException(e.getLocalizedMessage(), e);
}
return null;
@@ -230,7 +226,8 @@ public class ECFConnection implements ISynchAsynchConnection {
if (!isConnected())
return null;
try {
- return IDFactory.getDefault().createID(namespace.getName(), new Object[] {connection.getConnectionID()});
+ return IDFactory.getDefault().createID(namespace.getName(),
+ new Object[] { connection.getConnectionID() });
} catch (final Exception e) {
logException("Exception in getLocalID", e);
return null;
@@ -262,9 +259,11 @@ public class ECFConnection implements ISynchAsynchConnection {
try {
final Object val = arg0.getProperty(OBJECT_PROPERTY_NAME);
if (val != null) {
- handler.handleAsynchEvent(new ECFConnectionObjectPacketEvent(this, arg0, val));
+ handler.handleAsynchEvent(new ECFConnectionObjectPacketEvent(
+ this, arg0, val));
} else {
- handler.handleAsynchEvent(new ECFConnectionPacketEvent(this, arg0));
+ handler.handleAsynchEvent(new ECFConnectionPacketEvent(this,
+ arg0));
}
} catch (final IOException e) {
logException("Exception in handleAsynchEvent", e);
@@ -276,7 +275,8 @@ public class ECFConnection implements ISynchAsynchConnection {
}
}
- public synchronized void sendAsynch(ID receiver, byte[] data) throws IOException {
+ public synchronized void sendAsynch(ID receiver, byte[] data)
+ throws IOException {
if (data == null)
throw new IOException("no data");
final Message aMsg = new Message();
@@ -290,7 +290,8 @@ public class ECFConnection implements ISynchAsynchConnection {
throw new IOException("not connected");
try {
if (receiver == null)
- throw new IOException("receiver cannot be null for xmpp instant messaging");
+ throw new IOException(
+ "receiver cannot be null for xmpp instant messaging");
else if (receiver instanceof XMPPID) {
final XMPPID rcvr = (XMPPID) receiver;
aMsg.setType(Message.Type.CHAT);
@@ -304,16 +305,19 @@ public class ECFConnection implements ISynchAsynchConnection {
aMsg.setTo(to);
connection.sendPacket(aMsg);
} else
- throw new IOException("receiver must be of type XMPPID or XMPPRoomID");
+ throw new IOException(
+ "receiver must be of type XMPPID or XMPPRoomID");
} catch (final XMPPException e) {
- final IOException result = new IOException("XMPPException in sendMessage: " + e.getMessage());
+ final IOException result = new IOException(
+ "XMPPException in sendMessage: " + e.getMessage());
result.setStackTrace(e.getStackTrace());
throw result;
}
}
}
- public synchronized Object sendSynch(ID receiver, byte[] data) throws IOException {
+ public synchronized Object sendSynch(ID receiver, byte[] data)
+ throws IOException {
if (data == null)
throw new IOException("data cannot be null");
// This is assumed to be disconnect...so we'll just disconnect
@@ -354,7 +358,8 @@ public class ECFConnection implements ISynchAsynchConnection {
for (final Iterator i = properties.keySet().iterator(); i.hasNext();) {
final Object keyo = i.next();
final Object val = properties.get(keyo);
- final String key = (keyo instanceof String) ? (String) keyo : keyo.toString();
+ final String key = (keyo instanceof String) ? (String) keyo
+ : keyo.toString();
if (val instanceof Boolean)
input.setProperty(key, ((Boolean) val).booleanValue());
else if (val instanceof Double)
@@ -372,7 +377,8 @@ public class ECFConnection implements ISynchAsynchConnection {
return input;
}
- public void sendMessage(ID target, ID thread, Type type, String subject, String body, Map properties2) throws IOException {
+ public void sendMessage(ID target, ID thread, Type type, String subject,
+ String body, Map properties2) throws IOException {
if (target == null)
throw new IOException("XMPP target for message cannot be null");
if (body == null)
@@ -389,7 +395,8 @@ public class ECFConnection implements ISynchAsynchConnection {
sendMessage(target, aMsg);
}
- public void sendPresenceUpdate(ID target, Presence presence) throws IOException {
+ public void sendPresenceUpdate(ID target, Presence presence)
+ throws IOException {
if (presence == null)
throw new IOException("presence cannot be null");
presence.setFrom(connection.getUser());
@@ -402,7 +409,8 @@ public class ECFConnection implements ISynchAsynchConnection {
}
}
- public void sendRosterAdd(String user, String name, String[] groups) throws IOException, XMPPException {
+ public void sendRosterAdd(String user, String name, String[] groups)
+ throws IOException, XMPPException {
final Roster r = getRoster();
r.createEntry(user, name, groups);
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPID.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPID.java
index 881a3f782..938080bdc 100644
--- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPID.java
+++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPID.java
@@ -10,7 +10,6 @@
*****************************************************************************/
package org.eclipse.ecf.provider.xmpp.identity;
-import java.net.URI;
import java.net.URISyntaxException;
import java.util.Hashtable;
import java.util.Iterator;
@@ -91,11 +90,10 @@ public class XMPPID extends BaseID implements IChatID, IFQID {
return node;
}
- URI uri;
- String username;
- String hostname;
- String resourcename;
- int port = -1;
+ protected String username;
+ protected String hostname;
+ protected String resourcename;
+ protected int port = -1;
public XMPPID(Namespace namespace, String unamehost)
throws URISyntaxException {
@@ -137,9 +135,6 @@ public class XMPPID extends BaseID implements IChatID, IFQID {
}
if (hostname == null)
hostname = remainder;
- uri = new URI(namespace.getScheme(), username, hostname, port,
- PATH_DELIMITER + ((resourcename == null) ? "" : resourcename),
- null, null);
}
protected int namespaceCompareTo(BaseID o) {
@@ -182,7 +177,7 @@ public class XMPPID extends BaseID implements IChatID, IFQID {
* @see org.eclipse.ecf.core.identity.BaseID#namespaceToExternalForm()
*/
protected String namespaceToExternalForm() {
- return uri.toASCIIString();
+ return getNamespace().getScheme()+"://"+getFQName();
}
public String getUsername() {
@@ -217,7 +212,7 @@ public class XMPPID extends BaseID implements IChatID, IFQID {
public String toString() {
final StringBuffer sb = new StringBuffer("XMPPID["); //$NON-NLS-1$
- sb.append(uri.toString()).append("]");
+ sb.append(toExternalForm()).append("]");
return sb.toString();
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPSID.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPSID.java
index 872908508..759e251a2 100644
--- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPSID.java
+++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/identity/XMPPSID.java
@@ -23,7 +23,7 @@ public class XMPPSID extends XMPPID {
public String toString() {
StringBuffer sb = new StringBuffer("XMPPSID["); //$NON-NLS-1$
- sb.append(uri.toString()).append("]"); //$NON-NLS-1$
+ sb.append(toExternalForm()).append("]"); //$NON-NLS-1$
return sb.toString();
}

Back to the top