|
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) { |