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 149912 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/ecf/internal/presence/ui/Messages.java (-1 / +3 lines)
Lines 17-23 Link Here
17
public class Messages extends NLS {
17
public class Messages extends NLS {
18
18
19
	private static final String BUNDLE_NAME = "org.eclipse.ecf.internal.presence.ui.messages"; //$NON-NLS-1$
19
	private static final String BUNDLE_NAME = "org.eclipse.ecf.internal.presence.ui.messages"; //$NON-NLS-1$
20
	
20
21
	public static String ChangePasswordDialog_1;
21
	public static String ChangePasswordDialog_1;
22
22
23
	public static String ChangePasswordDialog_CHANGE_PASSWORD;
23
	public static String ChangePasswordDialog_CHANGE_PASSWORD;
Lines 68-73 Link Here
68
	public static String ChatRoomManagerView_ENTERED_MESSAGE;
68
	public static String ChatRoomManagerView_ENTERED_MESSAGE;
69
	
69
	
70
	public static String ChatRoomManagerView_LEFT_MESSAGE;
70
	public static String ChatRoomManagerView_LEFT_MESSAGE;
71
	
72
	public static String ChatRoomManagerView_NICKCHANGE_MESSAGE;
71
73
72
	public static String ChatRoomManagerView_JOIN_COMMAND;
74
	public static String ChatRoomManagerView_JOIN_COMMAND;
73
	
75
	
(-)src/org/eclipse/ecf/internal/presence/ui/messages.properties (+1 lines)
Lines 113-118 Link Here
113
ChatRoomManagerView_ENTERED_MESSAGE={0} entered
113
ChatRoomManagerView_ENTERED_MESSAGE={0} entered
114
ChatRoomView_NOT_CONNECTED_MESSAGE=Not connected to chat room
114
ChatRoomView_NOT_CONNECTED_MESSAGE=Not connected to chat room
115
ChatRoomManagerView_LEFT_MESSAGE={0} left
115
ChatRoomManagerView_LEFT_MESSAGE={0} left
116
ChatRoomManagerView_NICKCHANGE_MESSAGE={0} is now known as {1}
116
ChangePasswordDialog_CHANGE_PASSWORD=Change Password
117
ChangePasswordDialog_CHANGE_PASSWORD=Change Password
117
ChatRoomManagerView_MESSAGE={0}: {1}\n
118
ChatRoomManagerView_MESSAGE={0}: {1}\n
118
ChatRoomView_TIME_FORMAT=HH:mm:ss
119
ChatRoomView_TIME_FORMAT=HH:mm:ss
(-)src/org/eclipse/ecf/presence/ui/chatroom/ChatRoomManagerView.java (+24 lines)
Lines 684-698 Link Here
684
			// setup participant listener
684
			// setup participant listener
685
			chatRoomContainer
685
			chatRoomContainer
686
					.addChatRoomParticipantListener(new IChatRoomParticipantListener() {
686
					.addChatRoomParticipantListener(new IChatRoomParticipantListener() {
687
						IUser participant;
688
						
687
						public void handlePresenceUpdated(ID fromID,
689
						public void handlePresenceUpdated(ID fromID,
688
								IPresence presence) {
690
								IPresence presence) {
689
							chatroom.handlePresence(fromID, presence);
691
							chatroom.handlePresence(fromID, presence);
690
						}
692
						}
691
693
692
						public void handleArrived(IUser participant) {
694
						public void handleArrived(IUser participant) {
695
							this.participant = participant;
693
						}
696
						}
694
697
695
						public void handleUpdated(IUser updatedParticipant) {
698
						public void handleUpdated(IUser updatedParticipant) {
699
							chatroom.renameParticipant(participant, updatedParticipant);
696
						}
700
						}
697
701
698
						public void handleDeparted(IUser participant) {
702
						public void handleDeparted(IUser participant) {
Lines 1154-1159 Link Here
1154
				}
1158
				}
1155
			}
1159
			}
1156
		}
1160
		}
1161
		
1162
		protected void renameParticipant(final IUser oldUser, final IUser newUser) {
1163
			Display.getDefault().asyncExec(new Runnable() {
1164
				public void run() {
1165
					if (oldUser != null)  {
1166
						ID id = oldUser.getID();
1167
						if (id != null) {
1168
							
1169
							ChatRoomParticipant p = new ChatRoomParticipant(id);
1170
							
1171
							appendText(getOutputText(), new ChatLine(NLS.bind(
1172
									Messages.ChatRoomManagerView_NICKCHANGE_MESSAGE,
1173
									getUsernameFromID(id), getUsernameFromID(newUser.getID())), null));
1174
							chatRoomParticipantViewer.remove(p);
1175
							chatRoomParticipantViewer.add(new ChatRoomParticipant(newUser.getID()));
1176
						}
1177
					}
1178
				}
1179
			});
1180
		}
1157
1181
1158
		protected void removeAllParticipants() {
1182
		protected void removeAllParticipants() {
1159
			Table t = chatRoomParticipantViewer.getTable();
1183
			Table t = chatRoomParticipantViewer.getTable();
(-)src/org/eclipse/ecf/internal/provider/irc/container/IRCRootContainer.java (-6 / +13 lines)
Lines 261-273 Link Here
261
						channel
261
						channel
262
								.fireContainerEvent(new ContainerDisconnectingEvent(
262
								.fireContainerEvent(new ContainerDisconnectingEvent(
263
										channel.getID(), channel.targetID));
263
										channel.getID(), channel.targetID));
264
						channel.firePresenceListeners(false,
264
						channel.firePresenceListeners(IRCChannelContainer.LEAVE_EVENT,
265
								new String[] { kicked });
265
								new String[] { kicked });
266
						channel
266
						channel
267
								.fireContainerEvent(new ContainerDisconnectedEvent(
267
								.fireContainerEvent(new ContainerDisconnectedEvent(
268
										channel.getID(), channel.targetID));
268
										channel.getID(), channel.targetID));
269
					} else {
269
					} else {
270
						channel.firePresenceListeners(false,
270
						channel.firePresenceListeners(IRCChannelContainer.LEAVE_EVENT,
271
								new String[] { kicked });
271
								new String[] { kicked });
272
					}
272
					}
273
				}
273
				}
Lines 281-288 Link Here
281
				trace("handleOnMode(" + arg0 + "," + arg1 + "," + arg2 + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
281
				trace("handleOnMode(" + arg0 + "," + arg1 + "," + arg2 + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
282
			}
282
			}
283
283
284
			public void onNick(IRCUser arg0, String arg1) {
284
			public void onNick(IRCUser user, String newnick) {
285
				trace("handleOnNick(" + arg0 + "," + arg1 + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
285
				trace("handleOnNick(" + user + "," + newnick + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
286
				
287
				String[] nick = new String[] { user.getNick(), newnick };
288
				
289
				for (Iterator i = channels.values().iterator(); i.hasNext();) {
290
					IRCChannelContainer c = (IRCChannelContainer) i.next();
291
					c.firePresenceListeners(IRCChannelContainer.NICK_EVENT, nick);
292
				}
286
			}
293
			}
287
294
288
			public void onNotice(String arg0, IRCUser arg1, String arg2) {
295
			public void onNotice(String arg0, IRCUser arg1, String arg2) {
Lines 295-301 Link Here
295
				IRCChannelContainer channel = (IRCChannelContainer) channels
302
				IRCChannelContainer channel = (IRCChannelContainer) channels
296
						.get(arg0);
303
						.get(arg0);
297
				if (channel != null) {
304
				if (channel != null) {
298
					channel.firePresenceListeners(false,
305
					channel.firePresenceListeners(IRCChannelContainer.LEAVE_EVENT,
299
							new String[] { getIRCUserName(arg1) });
306
							new String[] { getIRCUserName(arg1) });
300
				}
307
				}
301
			}
308
			}
Lines 818-824 Link Here
818
			showMessage(null, NLS.bind(Messages.IRCRootContainer_353_Error,
825
			showMessage(null, NLS.bind(Messages.IRCRootContainer_353_Error,
819
					channel));
826
					channel));
820
		} else
827
		} else
821
			container.firePresenceListeners(true, strings);
828
			container.firePresenceListeners(IRCChannelContainer.JOIN_EVENT, strings);
822
	}
829
	}
823
830
824
	protected class ReplyHandler {
831
	protected class ReplyHandler {
(-)src/org/eclipse/ecf/internal/provider/irc/container/IRCChannelContainer.java (-5 / +45 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *    Composent, Inc. - initial API and implementation
9
 *    Composent, Inc. - initial API and implementation
10
 *    Jacek Pospychala <jacek.pospychala@pl.ibm.com> - bug 149912
10
 *****************************************************************************/
11
 *****************************************************************************/
11
package org.eclipse.ecf.internal.provider.irc.container;
12
package org.eclipse.ecf.internal.provider.irc.container;
12
13
Lines 28-33 Link Here
28
import org.eclipse.ecf.core.identity.Namespace;
29
import org.eclipse.ecf.core.identity.Namespace;
29
import org.eclipse.ecf.core.identity.StringID;
30
import org.eclipse.ecf.core.identity.StringID;
30
import org.eclipse.ecf.core.security.IConnectContext;
31
import org.eclipse.ecf.core.security.IConnectContext;
32
import org.eclipse.ecf.core.user.IUser;
31
import org.eclipse.ecf.core.user.User;
33
import org.eclipse.ecf.core.user.User;
32
import org.eclipse.ecf.core.util.ECFException;
34
import org.eclipse.ecf.core.util.ECFException;
33
import org.eclipse.ecf.core.util.TimeoutException;
35
import org.eclipse.ecf.core.util.TimeoutException;
Lines 49-54 Link Here
49
51
50
	private static final long CONNECT_TIMEOUT = 10000;
52
	private static final long CONNECT_TIMEOUT = 10000;
51
53
54
	protected static final int JOIN_EVENT = 1;
55
56
	protected static final int LEAVE_EVENT = 2;
57
	
58
	protected static final int NICK_EVENT = 3;
59
52
	protected List participantListeners = new ArrayList();
60
	protected List participantListeners = new ArrayList();
53
	protected IRCRootContainer rootContainer;
61
	protected IRCRootContainer rootContainer;
54
	protected IRCUser ircUser = null;
62
	protected IRCUser ircUser = null;
Lines 88-94 Link Here
88
96
89
	protected void handleUserQuit(String name) {
97
	protected void handleUserQuit(String name) {
90
		if (containsChannelParticipant(createIDFromString(name)) != null)
98
		if (containsChannelParticipant(createIDFromString(name)) != null)
91
			firePresenceListeners(false, new String[] { name });
99
			firePresenceListeners(LEAVE_EVENT, new String[] { name });
92
	}
100
	}
93
101
94
	private IPresence createPresence(final boolean available) {
102
	private IPresence createPresence(final boolean available) {
Lines 153-161 Link Here
153
		return null;
161
		return null;
154
	}
162
	}
155
163
156
	protected void firePresenceListeners(boolean joined, String[] users) {
164
	/**
165
	 * Fires presence change events.
166
	 * 
167
	 * {@link #JOIN_EVENT} indicates new users on channel.
168
	 * {@link #LEAVE_EVENT} indicates users leaving channel.
169
	 * {@link #NICK_EVENT} indicates users changing their names. users array contains pairs
170
	 * of old and new nicknames.
171
	 * 
172
	 * @param event either one of {@link #JOIN_EVENT}, {@link #LEAVE_EVENT} or {@link #NICK_EVENT}.
173
	 * @param users users that have changed.
174
	 */
175
	protected void firePresenceListeners(int event, String[] users) {
157
		for (int j = 0; j < users.length; j++) {
176
		for (int j = 0; j < users.length; j++) {
158
			if (joined) {
177
			if (event == JOIN_EVENT) {
159
				if (isChannelOperator(users[j]))
178
				if (isChannelOperator(users[j]))
160
					setChannelOperator(users[j]);
179
					setChannelOperator(users[j]);
161
				ID participantID = createIDFromString(users[j]);
180
				ID participantID = createIDFromString(users[j]);
Lines 170-176 Link Here
170
						l.handlePresenceUpdated(participantID, createPresence(true));
189
						l.handlePresenceUpdated(participantID, createPresence(true));
171
					}
190
					}
172
				}
191
				}
173
			} else {
192
			} else if (event == LEAVE_EVENT) {
174
				ID removeID = removeChannelParticipant(createIDFromString(users[j]));
193
				ID removeID = removeChannelParticipant(createIDFromString(users[j]));
175
				if (removeID != null) {
194
				if (removeID != null) {
176
					// Notify all listeners
195
					// Notify all listeners
Lines 184-189 Link Here
184
					}
203
					}
185
204
186
				}
205
				}
206
			} else if (event == NICK_EVENT) {
207
				if (isChannelOperator(users[j]))
208
					setChannelOperator(users[j]);
209
				ID userID = removeChannelParticipant(createIDFromString(users[j]));
210
				ID addID = createIDFromString(users[j+1]);
211
				
212
				if ((userID != null) && (addChannelParticipant(addID))) {
213
					for (Iterator i = participantListeners.iterator(); i.hasNext();) {
214
						IChatRoomParticipantListener l = (IChatRoomParticipantListener) i.next();
215
						
216
						IUser user = new User(userID);
217
						IUser newNickname = new User(addID);
218
						if (isChannelOperator(users[j]))
219
							setChannelOperator(users[j]);
220
						
221
						l.handleArrived(user);
222
						l.handleUpdated(newNickname);
223
					}
224
				}
225
				
226
				j++;
187
			}
227
			}
188
		}
228
		}
189
	}
229
	}
Lines 217-223 Link Here
217
				}
257
				}
218
			}
258
			}
219
		} else
259
		} else
220
			firePresenceListeners(true, new String[] { getIRCUserName(user) });
260
			firePresenceListeners(JOIN_EVENT, new String[] { getIRCUserName(user) });
221
	}
261
	}
222
262
223
	protected void fireContainerEvent(IContainerEvent event) {
263
	protected void fireContainerEvent(IContainerEvent event) {

Return to bug 149912