Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 188583
Collapse All | Expand All

(-)src/org/eclipse/ecf/protocol/msn/NotificationSession.java (-1 / +1 lines)
Lines 124-130 Link Here
124
	private void retrieveBuddyList() throws IOException {
124
	private void retrieveBuddyList() throws IOException {
125
		write("SYN", "0 0"); //$NON-NLS-1$ //$NON-NLS-2$
125
		write("SYN", "0 0"); //$NON-NLS-1$ //$NON-NLS-2$
126
126
127
		BufferedReader reader = new BufferedReader(new InputStreamReader(getInputStream()));
127
		BufferedReader reader = new BufferedReader(new InputStreamReader(getInputStream(), "UTF-8")); //$NON-NLS-1$
128
		String input = reader.readLine();
128
		String input = reader.readLine();
129
		while (input == null || !input.startsWith("SYN")) { //$NON-NLS-1$
129
		while (input == null || !input.startsWith("SYN")) { //$NON-NLS-1$
130
			input = reader.readLine();
130
			input = reader.readLine();
(-)src/org/eclipse/ecf/protocol/msn/ChatSession.java (-8 / +3 lines)
Lines 52-59 Link Here
52
52
53
	private final String email = client.getUserEmail();
53
	private final String email = client.getUserEmail();
54
54
55
	private boolean joined = false;
56
57
	/**
55
	/**
58
	 * Create a new ChatSession that connects to the given host.
56
	 * Create a new ChatSession that connects to the given host.
59
	 * 
57
	 * 
Lines 141-148 Link Here
141
			}
139
			}
142
		}
140
		}
143
		write("CAL", email); //$NON-NLS-1$
141
		write("CAL", email); //$NON-NLS-1$
144
		while (!joined);
145
		joined = false;
146
	}
142
	}
147
143
148
	/**
144
	/**
Lines 267-273 Link Here
267
					contact = new Contact(split[1], split[2]);
263
					contact = new Contact(split[1], split[2]);
268
				}
264
				}
269
				contacts.add(contact);
265
				contacts.add(contact);
270
				joined = true;
271
				fireContactJoinedEvent(contact);
266
				fireContactJoinedEvent(contact);
272
			} else if (lines[i].startsWith("BYE")) { //$NON-NLS-1$
267
			} else if (lines[i].startsWith("BYE")) { //$NON-NLS-1$
273
				final String[] split = StringUtils.splitOnSpace(lines[i]);
268
				final String[] split = StringUtils.splitOnSpace(lines[i]);
Lines 296-303 Link Here
296
					final int count = Integer.parseInt(split[3]);
291
					final int count = Integer.parseInt(split[3]);
297
					split = StringUtils.split(contents[index - 1], "\r\n\r\n"); //$NON-NLS-1$
292
					split = StringUtils.split(contents[index - 1], "\r\n\r\n"); //$NON-NLS-1$
298
293
299
					final int text = count - (split[0].length() + 4);
294
					final int text = count - (split[0].getBytes("UTF-8").length + 4); //$NON-NLS-1$
300
					fireMessageReceivedEvent(contact, split[1].substring(0, text));
295
					fireMessageReceivedEvent(contact, new String(split[1].getBytes("UTF-8"), 0, text, "UTF-8")); //$NON-NLS-1$ //$NON-NLS-2$
301
				}
296
				}
302
			}
297
			}
303
		}
298
		}
Lines 336-342 Link Here
336
				+ "Content-Type: text/plain; charset=UTF-8\r\n" //$NON-NLS-1$
331
				+ "Content-Type: text/plain; charset=UTF-8\r\n" //$NON-NLS-1$
337
				+ "X-MMS-IM-Format: FN=MS%20Sans%20Serif; EF=; CO=0; PF=0\r\n\r\n" //$NON-NLS-1$
332
				+ "X-MMS-IM-Format: FN=MS%20Sans%20Serif; EF=; CO=0; PF=0\r\n\r\n" //$NON-NLS-1$
338
				+ message;
333
				+ message;
339
		write("MSG", "N " + message.length() + "\r\n" + message, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
334
		write("MSG", "N " + message.getBytes("UTF-8").length + "\r\n" + message, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
340
	}
335
	}
341
336
342
	/**
337
	/**
(-)src/org/eclipse/ecf/protocol/msn/Session.java (-12 / +7 lines)
Lines 10-18 Link Here
10
 ******************************************************************************/
10
 ******************************************************************************/
11
package org.eclipse.ecf.protocol.msn;
11
package org.eclipse.ecf.protocol.msn;
12
12
13
import java.io.IOException;
13
import java.io.*;
14
import java.io.InputStream;
15
import java.io.OutputStream;
16
import java.net.Socket;
14
import java.net.Socket;
17
import java.util.ArrayList;
15
import java.util.ArrayList;
18
16
Lines 63-69 Link Here
63
	 * A thread used to wait indefinitely for incoming messages from the server.
61
	 * A thread used to wait indefinitely for incoming messages from the server.
64
	 */
62
	 */
65
	private IdleThread idleThread;
63
	private IdleThread idleThread;
66
	
64
67
	private boolean closed = false;
65
	private boolean closed = false;
68
66
69
	Session(MsnClient client) {
67
	Session(MsnClient client) {
Lines 117-124 Link Here
117
	final void openSocket(String host) throws IOException {
115
	final void openSocket(String host) throws IOException {
118
		closed = false;
116
		closed = false;
119
		int index = host.indexOf(':');
117
		int index = host.indexOf(':');
120
		openSocket(host.substring(0, index), Integer.parseInt(host
118
		openSocket(host.substring(0, index), Integer.parseInt(host.substring(index + 1)));
121
				.substring(index + 1)));
122
	}
119
	}
123
120
124
	final void openSocket(String ip, int port) throws IOException {
121
	final void openSocket(String ip, int port) throws IOException {
Lines 144-152 Link Here
144
		int read = is.read(buffer);
141
		int read = is.read(buffer);
145
		if (read < 1) {
142
		if (read < 1) {
146
			return null;
143
			return null;
147
		} else {
148
			return new String(buffer, 0, read).trim();
149
		}
144
		}
145
		return new String(buffer, 0, read, "UTF-8").trim(); //$NON-NLS-1$
150
	}
146
	}
151
147
152
	/**
148
	/**
Lines 164-170 Link Here
164
	 *             channel.
160
	 *             channel.
165
	 */
161
	 */
166
	private final void write(String input, boolean newline) throws IOException {
162
	private final void write(String input, boolean newline) throws IOException {
167
		byte[] bytes = newline ? (input + "\r\n").getBytes() : input.getBytes(); //$NON-NLS-1$
163
		byte[] bytes = newline ? (input + "\r\n").getBytes("UTF-8") : input.getBytes("UTF-8"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
168
		os.write(bytes);
164
		os.write(bytes);
169
		os.flush();
165
		os.flush();
170
	}
166
	}
Lines 201-208 Link Here
201
	 *             If an I/O error occurs while attempting to write to the
197
	 *             If an I/O error occurs while attempting to write to the
202
	 *             channel.
198
	 *             channel.
203
	 */
199
	 */
204
	final void write(String command, String parameters, boolean newline)
200
	final void write(String command, String parameters, boolean newline) throws IOException {
205
			throws IOException {
206
		transactionID++;
201
		transactionID++;
207
		write(command + ' ' + transactionID + ' ' + parameters, newline);
202
		write(command + ' ' + transactionID + ' ' + parameters, newline);
208
	}
203
	}
Lines 273-279 Link Here
273
			idleThread.start();
268
			idleThread.start();
274
		}
269
		}
275
	}
270
	}
276
	
271
277
	final boolean isClosed() {
272
	final boolean isClosed() {
278
		return closed;
273
		return closed;
279
	}
274
	}

Return to bug 188583