Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--protocols/bundles/org.eclipse.ecf.protocol.msn/src/org/eclipse/ecf/protocol/msn/ChatSession.java5
-rw-r--r--protocols/bundles/org.eclipse.ecf.protocol.msn/src/org/eclipse/ecf/protocol/msn/DispatchSession.java9
-rw-r--r--protocols/bundles/org.eclipse.ecf.protocol.msn/src/org/eclipse/ecf/protocol/msn/Session.java8
3 files changed, 14 insertions, 8 deletions
diff --git a/protocols/bundles/org.eclipse.ecf.protocol.msn/src/org/eclipse/ecf/protocol/msn/ChatSession.java b/protocols/bundles/org.eclipse.ecf.protocol.msn/src/org/eclipse/ecf/protocol/msn/ChatSession.java
index 3612c5439..161494acb 100644
--- a/protocols/bundles/org.eclipse.ecf.protocol.msn/src/org/eclipse/ecf/protocol/msn/ChatSession.java
+++ b/protocols/bundles/org.eclipse.ecf.protocol.msn/src/org/eclipse/ecf/protocol/msn/ChatSession.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 Remy Suen
+ * Copyright (c) 2005, 2008 Remy Suen
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* Remy Suen <remy.suen@gmail.com> - initial API and implementation
+ * Stoyan Boshev <s.boshev@prosyst.com> - [MSN] Session and subclasses needs to handle whitespace and exceptions better
******************************************************************************/
package org.eclipse.ecf.protocol.msn;
@@ -289,7 +290,7 @@ public final class ChatSession extends Session {
final Contact contact = findContact(split[1]);
final int count = Integer.parseInt(split[3]);
- split = StringUtils.split(contents[index - 1], "\r\n\r\n"); //$NON-NLS-1$
+ split = StringUtils.split(contents[index - 1], "\r\n\r\n", 2); //$NON-NLS-1$
final int text = count - (split[0].getBytes("UTF-8").length + 4); //$NON-NLS-1$
fireMessageReceivedEvent(contact, new String(split[1].getBytes("UTF-8"), 0, text, "UTF-8")); //$NON-NLS-1$ //$NON-NLS-2$
diff --git a/protocols/bundles/org.eclipse.ecf.protocol.msn/src/org/eclipse/ecf/protocol/msn/DispatchSession.java b/protocols/bundles/org.eclipse.ecf.protocol.msn/src/org/eclipse/ecf/protocol/msn/DispatchSession.java
index 2951d4e3c..832e80ead 100644
--- a/protocols/bundles/org.eclipse.ecf.protocol.msn/src/org/eclipse/ecf/protocol/msn/DispatchSession.java
+++ b/protocols/bundles/org.eclipse.ecf.protocol.msn/src/org/eclipse/ecf/protocol/msn/DispatchSession.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 Remy Suen
+ * Copyright (c) 2005, 2008 Remy Suen
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* Remy Suen <remy.suen@gmail.com> - initial API and implementation
+ * Stoyan Boshev <s.boshev@prosyst.com> - [MSN] Session and subclasses needs to handle whitespace and exceptions better
******************************************************************************/
package org.eclipse.ecf.protocol.msn;
@@ -66,7 +67,7 @@ class DispatchSession extends Session {
*/
ResponseCommand connect(String username) throws ConnectException, IOException {
write("VER", "MSNP11 CVR0"); //$NON-NLS-1$ //$NON-NLS-2$
- String input = super.read();
+ String input = super.read().trim();
if (!input.startsWith("VER")) { //$NON-NLS-1$
// TODO: throw a more descriptive exception
throw new ConnectException("The server did not respond properly.");
@@ -74,14 +75,14 @@ class DispatchSession extends Session {
write("CVR", "0x040c winnt 5.1 i386 MSNMSGR 7.0.0813 msmsgs " //$NON-NLS-1$ //$NON-NLS-2$
+ username);
- input = super.read();
+ input = super.read().trim();
if (!input.startsWith("CVR")) { //$NON-NLS-1$
// TODO: throw a more descriptive exception
throw new ConnectException("The server did not respond properly.");
}
write("USR", "TWN I " + username); //$NON-NLS-1$ //$NON-NLS-2$
- return new ResponseCommand(super.read());
+ return new ResponseCommand(super.read().trim());
}
/**
diff --git a/protocols/bundles/org.eclipse.ecf.protocol.msn/src/org/eclipse/ecf/protocol/msn/Session.java b/protocols/bundles/org.eclipse.ecf.protocol.msn/src/org/eclipse/ecf/protocol/msn/Session.java
index 904cd430c..488bfe92b 100644
--- a/protocols/bundles/org.eclipse.ecf.protocol.msn/src/org/eclipse/ecf/protocol/msn/Session.java
+++ b/protocols/bundles/org.eclipse.ecf.protocol.msn/src/org/eclipse/ecf/protocol/msn/Session.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 Remy Suen
+ * Copyright (c) 2005, 2008 Remy Suen
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* Remy Suen <remy.suen@gmail.com> - initial API and implementation
+ * Stoyan Boshev <s.boshev@prosyst.com> - [MSN] Session and subclasses needs to handle whitespace and exceptions better
******************************************************************************/
package org.eclipse.ecf.protocol.msn;
@@ -142,7 +143,7 @@ abstract class Session {
if (read < 1) {
return null;
}
- return new String(buffer, 0, read, "UTF-8").trim(); //$NON-NLS-1$
+ return new String(buffer, 0, read, "UTF-8"); //$NON-NLS-1$
}
/**
@@ -287,6 +288,9 @@ abstract class Session {
read();
} catch (IOException e) {
return;
+ } catch (RuntimeException e) {
+ System.out.println("Exception occurred: ");
+ e.printStackTrace();
}
}
}

Back to the top