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/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 816-822 Link Here
816
			showMessage(null, NLS.bind(Messages.IRCRootContainer_353_Error,
823
			showMessage(null, NLS.bind(Messages.IRCRootContainer_353_Error,
817
					channel));
824
					channel));
818
		} else
825
		} else
819
			container.firePresenceListeners(true, strings);
826
			container.firePresenceListeners(IRCChannelContainer.JOIN_EVENT, strings);
820
	}
827
	}
821
828
822
	protected class ReplyHandler {
829
	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) {
(-)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 114-119 Link Here
114
ChatRoomManagerView_USERS_IN_CHAT_ROOM = {0} users
114
ChatRoomManagerView_USERS_IN_CHAT_ROOM = {0} users
115
ChatRoomView_NOT_CONNECTED_MESSAGE=Not connected to chat room
115
ChatRoomView_NOT_CONNECTED_MESSAGE=Not connected to chat room
116
ChatRoomManagerView_LEFT_MESSAGE={0} left
116
ChatRoomManagerView_LEFT_MESSAGE={0} left
117
ChatRoomManagerView_NICKCHANGE_MESSAGE={0} is now known as {1}
117
ChangePasswordDialog_CHANGE_PASSWORD=Change Password
118
ChangePasswordDialog_CHANGE_PASSWORD=Change Password
118
ChatRoomManagerView_MESSAGE={0}: {1}\n
119
ChatRoomManagerView_MESSAGE={0}: {1}\n
119
ChatRoomView_TIME_FORMAT=HH:mm:ss
120
ChatRoomView_TIME_FORMAT=HH:mm:ss
(-)src/org/eclipse/ecf/presence/ui/chatroom/ChatRoomManagerView.java (-2 / +25 lines)
Lines 555-571 Link Here
555
			});
555
			});
556
			// setup participant listener
556
			// setup participant listener
557
			chatRoomContainer.addChatRoomParticipantListener(new IChatRoomParticipantListener() {
557
			chatRoomContainer.addChatRoomParticipantListener(new IChatRoomParticipantListener() {
558
				IUser participant;
559
558
				public void handlePresenceUpdated(ID fromID, IPresence presence) {
560
				public void handlePresenceUpdated(ID fromID, IPresence presence) {
559
					chatroom.handlePresence(fromID, presence);
561
					chatroom.handlePresence(fromID, presence);
560
				}
562
				}
561
563
562
				public void handleArrived(IUser participant) {
564
				public void handleArrived(IUser p) {
565
					this.participant = p;
563
				}
566
				}
564
567
565
				public void handleUpdated(IUser updatedParticipant) {
568
				public void handleUpdated(IUser updatedParticipant) {
569
					chatroom.renameParticipant(participant, updatedParticipant);
566
				}
570
				}
567
571
568
				public void handleDeparted(IUser participant) {
572
				public void handleDeparted(IUser p) {
573
					//
569
				}
574
				}
570
			});
575
			});
571
			chatRoomContainer.addListener(new IContainerListener() {
576
			chatRoomContainer.addListener(new IContainerListener() {
Lines 1009-1014 Link Here
1009
			}
1014
			}
1010
		}
1015
		}
1011
1016
1017
		protected void renameParticipant(final IUser oldUser, final IUser newUser) {
1018
			Display.getDefault().asyncExec(new Runnable() {
1019
				public void run() {
1020
					if (oldUser != null) {
1021
						ID id = oldUser.getID();
1022
						if (id != null) {
1023
1024
							ChatRoomParticipant p = new ChatRoomParticipant(id);
1025
1026
							appendText(chatRoomTab, getOutputText(), new ChatLine(NLS.bind(Messages.ChatRoomManagerView_NICKCHANGE_MESSAGE, getUsernameFromID(id), getUsernameFromID(newUser.getID())), null));
1027
							chatRoomParticipantViewer.remove(p);
1028
							chatRoomParticipantViewer.add(new ChatRoomParticipant(newUser.getID()));
1029
						}
1030
					}
1031
				}
1032
			});
1033
		}
1034
1012
		protected void removeAllParticipants() {
1035
		protected void removeAllParticipants() {
1013
			Table t = chatRoomParticipantViewer.getTable();
1036
			Table t = chatRoomParticipantViewer.getTable();
1014
			for (int i = 0; i < t.getItemCount(); i++) {
1037
			for (int i = 0; i < t.getItemCount(); i++) {

Return to bug 149912