diff options
| author | slewis | 2005-05-08 16:34:10 +0000 |
|---|---|---|
| committer | slewis | 2005-05-08 16:34:10 +0000 |
| commit | 6840e60b6c04ea1ece75c3a9d5b9a82914a5c847 (patch) | |
| tree | 98b5e820a7c7b5b6cc2ef90391a85ca3aa9f6d3a | |
| parent | 012eb7401825b997e1c95cdc4d014bee40d47be5 (diff) | |
| download | org.eclipse.ecf-6840e60b6c04ea1ece75c3a9d5b9a82914a5c847.tar.gz org.eclipse.ecf-6840e60b6c04ea1ece75c3a9d5b9a82914a5c847.tar.xz org.eclipse.ecf-6840e60b6c04ea1ece75c3a9d5b9a82914a5c847.zip | |
Fixes for deadlock bug caused by problem in smack library
3 files changed, 38 insertions, 53 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/.options b/providers/bundles/org.eclipse.ecf.provider.xmpp/.options index 2acff57ac..91528a463 100644 --- a/providers/bundles/org.eclipse.ecf.provider.xmpp/.options +++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/.options @@ -3,5 +3,5 @@ org.eclipse.ecf.provider.xmpp/debug/filter = * org.eclipse.ecf.provider.xmpp/debug/flag = true org.eclipse.ecf.provider.xmpp/debug/smackconnection = true org.eclipse.ecf.provider.xmpp/debug/xmppsharedobject = true -org.eclipse.ecf.provider.xmpp/debug/xmpppresencesharedobject = true -org.eclipse.ecf.provider.xmpp/debug/smackdebug = true
\ No newline at end of file +org.eclipse.ecf.provider.xmpp/debug/xmpppresencesharedobject = false +org.eclipse.ecf.provider.xmpp/debug/smackdebug = false
\ No newline at end of file diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPClientSOContainer.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPClientSOContainer.java index 622b9d9e1..b7927bc6b 100644 --- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPClientSOContainer.java +++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPClientSOContainer.java @@ -98,13 +98,6 @@ public class XMPPClientSOContainer extends ClientSOContainer { if (conn != null && sharedObject != null) { sharedObject.setConnection(conn.getXMPPConnection()); } - // If we've got roster data then pass it onto shared object - if (serverData != null && serverData instanceof Roster) { - Roster roster = (Roster) serverData; - if (sharedObject != null) { - sharedObject.handleRoster(roster); - } - } return originalTarget; } diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/smack/ChatConnection.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/smack/ChatConnection.java index 754060a62..15c7a54d3 100644 --- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/smack/ChatConnection.java +++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/smack/ChatConnection.java @@ -34,6 +34,7 @@ import org.jivesoftware.smack.packet.Presence; public class ChatConnection implements ISynchAsynchConnection, IIMMessageSender { + public static final String CLIENT_TYPE = "ECF_XMPP"; public static final Trace trace = Trace.create("smackconnection"); public static final Trace smack = Trace.create("smackdebug"); protected static final String STRING_ENCODING = "UTF-8"; @@ -86,39 +87,39 @@ public class ChatConnection implements ISynchAsynchConnection, IIMMessageSender XMPPConnection.DEBUG_ENABLED = true; } } - + protected String getPasswordForObject(Object data) { + String password = null; + try { + password = (String) data; + } catch (ClassCastException e) { + return null; + } + return password; + } + + protected XMPPID getXMPPID(ID remote) throws IOException { + XMPPID jabberID = null; + try { + jabberID = (XMPPID) remote; + } catch (ClassCastException e) { + IOException throwMe = new IOException(e.getMessage()); + throwMe.setStackTrace(e.getStackTrace()); + throw throwMe; + } + return jabberID; + } public synchronized Object connect(ID remote, Object data, int timeout) throws IOException { if (connection != null) - throw new IOException("Currently connected"); - debug("connect(" + remote + "," + data + "," + timeout + ")"); + throw new IOException("already connected"); if (timeout > 0) SmackConfiguration.setPacketReplyTimeout(timeout); - Roster.setDefaultSubscriptionMode(Roster.SUBSCRIPTION_MANUAL); - XMPPID jabberURI = null; - try { - jabberURI = (XMPPID) remote; - } catch (ClassCastException e) { - IOException throwMe = new IOException(e.getMessage()); - throwMe.setStackTrace(e.getStackTrace()); - throw throwMe; - } + XMPPID jabberURI = getXMPPID(remote); String username = jabberURI.getUsername(); serverName = jabberURI.getHostname(); - String password = null; - if (data == null) - throw new IOException("data parameter (password) must be provided"); - try { - password = (String) data; - } catch (ClassCastException e) { - IOException throwMe = new IOException(e.getClass().getName() - + " wrapped: " + e.getMessage()); - throwMe.setStackTrace(e.getStackTrace()); - throw throwMe; - } - Roster roster = null; + String password = getPasswordForObject(data); try { if (serverPort == -1) { connection = new XMPPConnection(serverName); @@ -126,21 +127,23 @@ public class ChatConnection implements ISynchAsynchConnection, IIMMessageSender connection = new XMPPConnection(serverName, serverPort); } connection.addPacketListener(new PacketListener() { - /* - * (non-Javadoc) - * - * @see org.jivesoftware.smack.PacketListener#processPacket(org.jivesoftware.smack.packet.Packet) - */ public void processPacket(Packet arg0) { handlePacket(arg0); } }, null); + connection.addConnectionListener(new ConnectionListener() { + public void connectionClosed() { + handleConnectionClosed(null); + } + + public void connectionClosedOnError(Exception e) { + handleConnectionClosed(e); + } + }); // Login - connection.login(username, (String) data, "ECF_XMPP"); + connection.login(username, (String) data, CLIENT_TYPE); isConnected = true; debug("User: " + username + " logged into " + serverName); - roster = getRoster(); - roster.reload(); } catch (XMPPException e) { if (connection != null) { connection.close(); @@ -149,18 +152,7 @@ public class ChatConnection implements ISynchAsynchConnection, IIMMessageSender result.setStackTrace(e.getStackTrace()); throw result; } - // Now setup listener - connection.addConnectionListener(new ConnectionListener() { - public void connectionClosed() { - handleConnectionClosed(null); - } - - public void connectionClosedOnError(Exception e) { - handleConnectionClosed(e); - } - }); - - return roster; + return null; } public synchronized void disconnect() throws IOException { |
