diff options
author | slewis | 2009-02-11 22:10:57 +0000 |
---|---|---|
committer | slewis | 2009-02-11 22:10:57 +0000 |
commit | ad914d2a5729363fd3b91cdaa8d6088f36007f62 (patch) | |
tree | d0c329860dcb08098ef53b43b8df38d4ff08ab7e /providers | |
parent | 8b33259cb249c92c67b10622277254d3272ba46e (diff) | |
download | org.eclipse.ecf-ad914d2a5729363fd3b91cdaa8d6088f36007f62.tar.gz org.eclipse.ecf-ad914d2a5729363fd3b91cdaa8d6088f36007f62.tar.xz org.eclipse.ecf-ad914d2a5729363fd3b91cdaa8d6088f36007f62.zip |
Changes to projects and features/map files to include org.eclipse.equinox.concurrent in ECF build and to depend upon classes rather than duplicate them in org.eclipse.ecf.core.util.
Diffstat (limited to 'providers')
3 files changed, 301 insertions, 152 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.irc/META-INF/MANIFEST.MF b/providers/bundles/org.eclipse.ecf.provider.irc/META-INF/MANIFEST.MF index 81fa80521..9cded1570 100644 --- a/providers/bundles/org.eclipse.ecf.provider.irc/META-INF/MANIFEST.MF +++ b/providers/bundles/org.eclipse.ecf.provider.irc/META-INF/MANIFEST.MF @@ -16,7 +16,8 @@ Bundle-RequiredExecutionEnvironment: CDC-1.1/Foundation-1.1, Export-Package: org.eclipse.ecf.internal.provider.irc;x-internal:=true, org.eclipse.ecf.internal.provider.irc.container;x-internal:=true, org.eclipse.ecf.internal.provider.irc.identity;x-internal:=true -Import-Package: org.eclipse.osgi.util;version="1.0.0", +Import-Package: org.eclipse.equinox.concurrent.future;version="1.0.0", + org.eclipse.osgi.util;version="1.0.0", org.osgi.framework;version="1.3.0", org.osgi.service.log;version="1.3.0", org.osgi.util.tracker;version="1.3.2" diff --git a/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/container/IRCChannelContainer.java b/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/container/IRCChannelContainer.java index 16ef7ff7f..863d2eac7 100644 --- a/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/container/IRCChannelContainer.java +++ b/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/container/IRCChannelContainer.java @@ -17,11 +17,11 @@ import org.eclipse.ecf.core.identity.*; import org.eclipse.ecf.core.security.IConnectContext; import org.eclipse.ecf.core.user.User; import org.eclipse.ecf.core.util.ECFException; -import org.eclipse.ecf.core.util.TimeoutException; import org.eclipse.ecf.internal.provider.irc.Messages; import org.eclipse.ecf.presence.IPresence; import org.eclipse.ecf.presence.chatroom.*; import org.eclipse.ecf.presence.im.IChatMessageSender; +import org.eclipse.equinox.concurrent.future.TimeoutException; import org.eclipse.osgi.util.NLS; import org.schwering.irc.lib.IRCUser; @@ -29,7 +29,8 @@ import org.schwering.irc.lib.IRCUser; * IContainer class used to represent a specific IRC channel (e.g. #eclipse-dev) * */ -public class IRCChannelContainer extends IRCAbstractContainer implements IChatMessageSender, IChatRoomContainer { +public class IRCChannelContainer extends IRCAbstractContainer implements + IChatMessageSender, IChatRoomContainer { private static final long CONNECT_TIMEOUT = 10000; @@ -47,7 +48,8 @@ public class IRCChannelContainer extends IRCAbstractContainer implements IChatMe protected IChatRoomMessageSender sender = new IChatRoomMessageSender() { public void sendMessage(String message) throws ECFException { - rootContainer.doSendChannelMessage(targetID.getName(), ircUser.toString(), message); + rootContainer.doSendChannelMessage(targetID.getName(), ircUser + .toString(), message); } }; @@ -59,19 +61,23 @@ public class IRCChannelContainer extends IRCAbstractContainer implements IChatMe /* * (non-Javadoc) * - * @see org.eclipse.ecf.presence.chatroom.IChatRoomContainer#addChatParticipantListener(org.eclipse.ecf.presence.chatroom.IChatRoomParticipantListener) + * @seeorg.eclipse.ecf.presence.chatroom.IChatRoomContainer# + * addChatParticipantListener + * (org.eclipse.ecf.presence.chatroom.IChatRoomParticipantListener) */ - public void addChatRoomParticipantListener(IChatRoomParticipantListener participantListener) { + public void addChatRoomParticipantListener( + IChatRoomParticipantListener participantListener) { participantListeners.add(participantListener); } - public void removeChatRoomParticipantListener(IChatRoomParticipantListener participantListener) { + public void removeChatRoomParticipantListener( + IChatRoomParticipantListener participantListener) { participantListeners.remove(participantListener); } protected void handleUserQuit(String name) { if (containsChannelParticipant(createIDFromString(name)) != null) - firePresenceListeners(false, new String[] {name}); + firePresenceListeners(false, new String[] { name }); } private IPresence createPresence(final boolean available) { @@ -81,7 +87,8 @@ public class IRCChannelContainer extends IRCAbstractContainer implements IChatMe Map properties = new HashMap(); public Mode getMode() { - return (available ? IPresence.Mode.AVAILABLE : IPresence.Mode.AWAY); + return (available ? IPresence.Mode.AVAILABLE + : IPresence.Mode.AWAY); } public Map getProperties() { @@ -93,7 +100,8 @@ public class IRCChannelContainer extends IRCAbstractContainer implements IChatMe } public Type getType() { - return (available ? IPresence.Type.AVAILABLE : IPresence.Type.UNAVAILABLE); + return (available ? IPresence.Type.AVAILABLE + : IPresence.Type.UNAVAILABLE); } public Object getAdapter(Class adapter) { @@ -117,7 +125,8 @@ public class IRCChannelContainer extends IRCAbstractContainer implements IChatMe protected ID removeChannelParticipant(ID participantID) { if (channelParticipants.remove(participantID)) return participantID; - ID operatorID = createIDFromString(OPERATOR_PREFIX + participantID.getName()); + ID operatorID = createIDFromString(OPERATOR_PREFIX + + participantID.getName()); if (channelParticipants.remove(operatorID)) return operatorID; return null; @@ -126,7 +135,8 @@ public class IRCChannelContainer extends IRCAbstractContainer implements IChatMe protected ID containsChannelParticipant(ID participantID) { if (channelParticipants.contains(participantID)) return participantID; - ID operatorID = createIDFromString(OPERATOR_PREFIX + participantID.getName()); + ID operatorID = createIDFromString(OPERATOR_PREFIX + + participantID.getName()); if (channelParticipants.contains(operatorID)) return operatorID; return null; @@ -140,21 +150,28 @@ public class IRCChannelContainer extends IRCAbstractContainer implements IChatMe ID participantID = createIDFromString(users[j]); if (addChannelParticipant(participantID)) { // Notify all listeners - for (Iterator i = participantListeners.iterator(); i.hasNext();) { - IChatRoomParticipantListener l = (IChatRoomParticipantListener) i.next(); + for (Iterator i = participantListeners.iterator(); i + .hasNext();) { + IChatRoomParticipantListener l = (IChatRoomParticipantListener) i + .next(); l.handleArrived(new User(participantID)); - l.handlePresenceUpdated(participantID, createPresence(true)); + l.handlePresenceUpdated(participantID, + createPresence(true)); } } } else { ID removeID = removeChannelParticipant(createIDFromString(users[j])); if (removeID != null) { // Notify all listeners - for (Iterator i = participantListeners.iterator(); i.hasNext();) { - IChatRoomParticipantListener l = (IChatRoomParticipantListener) i.next(); - - l.handlePresenceUpdated(removeID, createPresence(false)); + for (Iterator i = participantListeners.iterator(); i + .hasNext();) { + IChatRoomParticipantListener l = (IChatRoomParticipantListener) i + .next(); + + l + .handlePresenceUpdated(removeID, + createPresence(false)); l.handleDeparted(new User(removeID)); } @@ -172,7 +189,9 @@ public class IRCChannelContainer extends IRCAbstractContainer implements IChatMe /* * (non-Javadoc) * - * @see org.eclipse.ecf.presence.chatroom.IChatRoomContainer#getChatMessageSender() + * @see + * org.eclipse.ecf.presence.chatroom.IChatRoomContainer#getChatMessageSender + * () */ public IChatRoomMessageSender getChatRoomMessageSender() { return sender; @@ -192,7 +211,7 @@ public class IRCChannelContainer extends IRCAbstractContainer implements IChatMe } } } else - firePresenceListeners(true, new String[] {getIRCUserName(user)}); + firePresenceListeners(true, new String[] { getIRCUserName(user) }); } protected void fireContainerEvent(IContainerEvent event) { @@ -202,18 +221,23 @@ public class IRCChannelContainer extends IRCAbstractContainer implements IChatMe /* * (non-Javadoc) * - * @see org.eclipse.ecf.core.IContainer#connect(org.eclipse.ecf.core.identity.ID, - * org.eclipse.ecf.core.security.IConnectContext) + * @see + * org.eclipse.ecf.core.IContainer#connect(org.eclipse.ecf.core.identity.ID, + * org.eclipse.ecf.core.security.IConnectContext) */ - public void connect(ID connectID, IConnectContext connectContext) throws ContainerConnectException { + public void connect(ID connectID, IConnectContext connectContext) + throws ContainerConnectException { // Actually do join here if (connectID == null) - throw new ContainerConnectException(Messages.IRCChannelContainer_Exception_TargetID_Null); + throw new ContainerConnectException( + Messages.IRCChannelContainer_Exception_TargetID_Null); if (connectWaiting) - throw new ContainerConnectException(Messages.IRCChannelContainer_Exception_Connecting); + throw new ContainerConnectException( + Messages.IRCChannelContainer_Exception_Connecting); // Get channel name String channelName = connectID.getName(); - fireContainerEvent(new ContainerConnectingEvent(this.getID(), connectID, connectContext)); + fireContainerEvent(new ContainerConnectingEvent(this.getID(), + connectID, connectContext)); // Get password via callback in connectContext String pw = getPasswordFromConnectContext(connectContext); synchronized (connectLock) { @@ -225,12 +249,20 @@ public class IRCChannelContainer extends IRCAbstractContainer implements IChatMe connectLock.wait(2000); } if (connectWaiting) - throw new TimeoutException(NLS.bind(Messages.IRCChannelContainer_Exception_Connect_Timeout, connectID.getName()), CONNECT_TIMEOUT); + throw new TimeoutException( + NLS + .bind( + Messages.IRCChannelContainer_Exception_Connect_Timeout, + connectID.getName()), + CONNECT_TIMEOUT); this.targetID = connectID; - fireContainerEvent(new ContainerConnectedEvent(this.getID(), this.targetID)); + fireContainerEvent(new ContainerConnectedEvent(this.getID(), + this.targetID)); } catch (Exception e) { this.targetID = null; - throw new ContainerConnectException(NLS.bind(Messages.IRCChannelContainer_Exception_Connect_Failed, connectID.getName()), e); + throw new ContainerConnectException(NLS.bind( + Messages.IRCChannelContainer_Exception_Connect_Failed, + connectID.getName()), e); } finally { connectWaiting = false; } @@ -267,7 +299,8 @@ public class IRCChannelContainer extends IRCAbstractContainer implements IChatMe * @see org.eclipse.ecf.core.IContainer#getConnectNamespace() */ public Namespace getConnectNamespace() { - return IDFactory.getDefault().getNamespaceByName(StringID.class.getName()); + return IDFactory.getDefault().getNamespaceByName( + StringID.class.getName()); } protected boolean isLocalUserChannelOperator() { @@ -277,7 +310,8 @@ public class IRCChannelContainer extends IRCAbstractContainer implements IChatMe protected boolean isLocalUserChannelOperator(String chOperator) { if (!isChannelOperator(chOperator)) return false; - String localUserName = (ircUser == null) ? null : (OPERATOR_PREFIX + ircUser.getNick()); + String localUserName = (ircUser == null) ? null + : (OPERATOR_PREFIX + ircUser.getNick()); if (localUserName == null) return false; if (chOperator.equals(localUserName)) @@ -289,7 +323,9 @@ public class IRCChannelContainer extends IRCAbstractContainer implements IChatMe this.channelOperator = channelOperator; } - public void sendChatMessage(ID toID, ID threadID, org.eclipse.ecf.presence.im.IChatMessage.Type type, String subject, String body, Map properties) throws ECFException { + public void sendChatMessage(ID toID, ID threadID, + org.eclipse.ecf.presence.im.IChatMessage.Type type, String subject, + String body, Map properties) throws ECFException { rootContainer.sendChatMessage(toID, body); } @@ -302,18 +338,25 @@ public class IRCChannelContainer extends IRCAbstractContainer implements IChatMe } public ID[] getChatRoomParticipants() { - return (ID[]) channelParticipants.toArray(new ID[channelParticipants.size()]); + return (ID[]) channelParticipants.toArray(new ID[channelParticipants + .size()]); } - /* (non-Javadoc) - * @see org.eclipse.ecf.presence.chatroom.IChatRoomContainer#getChatRoomAdminSender() + /* + * (non-Javadoc) + * + * @see + * org.eclipse.ecf.presence.chatroom.IChatRoomContainer#getChatRoomAdminSender + * () */ public IChatRoomAdminSender getChatRoomAdminSender() { synchronized (this) { if (adminSender == null) { adminSender = new IChatRoomAdminSender() { - public void sendSubjectChange(String newsubject) throws ECFException { - rootContainer.doSendSubjectChangeMessage(targetID.getName(), newsubject); + public void sendSubjectChange(String newsubject) + throws ECFException { + rootContainer.doSendSubjectChangeMessage(targetID + .getName(), newsubject); } }; } diff --git a/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/container/IRCRootContainer.java b/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/container/IRCRootContainer.java index 79ca18bbb..b97890288 100644 --- a/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/container/IRCRootContainer.java +++ b/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/container/IRCRootContainer.java @@ -17,7 +17,6 @@ import org.eclipse.ecf.core.events.*; import org.eclipse.ecf.core.identity.*; import org.eclipse.ecf.core.security.IConnectContext; import org.eclipse.ecf.core.util.ECFException; -import org.eclipse.ecf.core.util.TimeoutException; import org.eclipse.ecf.internal.provider.irc.Activator; import org.eclipse.ecf.internal.provider.irc.Messages; import org.eclipse.ecf.internal.provider.irc.identity.IRCID; @@ -27,6 +26,7 @@ import org.eclipse.ecf.presence.history.IHistory; import org.eclipse.ecf.presence.history.IHistoryManager; import org.eclipse.ecf.presence.im.IChatMessageSender; import org.eclipse.ecf.presence.im.IChatMessage.Type; +import org.eclipse.equinox.concurrent.future.TimeoutException; import org.eclipse.osgi.util.NLS; import org.schwering.irc.lib.*; import org.schwering.irc.lib.ssl.SSLIRCConnection; @@ -37,7 +37,10 @@ import org.schwering.irc.lib.ssl.SSLIRCConnection; * function as both a manager of IRC channels and as an IRC channel itself. * */ -public class IRCRootContainer extends IRCAbstractContainer implements IContainer, IChatMessageSender, IChatRoomInvitationSender, IChatRoomManager, IChatRoomContainer, IRCMessageChannel, IChatRoomContainerOptionsAdapter { +public class IRCRootContainer extends IRCAbstractContainer implements + IContainer, IChatMessageSender, IChatRoomInvitationSender, + IChatRoomManager, IChatRoomContainer, IRCMessageChannel, + IChatRoomContainerOptionsAdapter { private static final long CONNECT_TIMEOUT = 20000; @@ -59,7 +62,8 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer public IRCRootContainer(ID localID) throws IDCreateException { this.localID = localID; - this.unknownID = IDFactory.getDefault().createStringID(Messages.IRCRootContainer_0); + this.unknownID = IDFactory.getDefault().createStringID( + Messages.IRCRootContainer_0); this.replyHandler = new ReplyHandler(); invitationListeners = new ArrayList(); } @@ -67,20 +71,28 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer /* * (non-Javadoc) * - * @see org.eclipse.ecf.core.IContainer#connect(org.eclipse.ecf.core.identity.ID, - * org.eclipse.ecf.core.security.IConnectContext) + * @see + * org.eclipse.ecf.core.IContainer#connect(org.eclipse.ecf.core.identity.ID, + * org.eclipse.ecf.core.security.IConnectContext) */ - public void connect(ID connectID, IConnectContext connectContext) throws ContainerConnectException { + public void connect(ID connectID, IConnectContext connectContext) + throws ContainerConnectException { if (connection != null) - throw new ContainerConnectException(Messages.IRCRootContainer_Exception_Already_Connected); + throw new ContainerConnectException( + Messages.IRCRootContainer_Exception_Already_Connected); if (connectID == null) - throw new ContainerConnectException(Messages.IRCRootContainer_Exception_TargetID_Null); + throw new ContainerConnectException( + Messages.IRCRootContainer_Exception_TargetID_Null); if (!(connectID instanceof IRCID)) - throw new ContainerConnectException(NLS.bind(Messages.IRCRootContainer_Exception_TargetID_Wrong_Type, new Object[] {targetID, IRCID.class.getName()})); + throw new ContainerConnectException(NLS.bind( + Messages.IRCRootContainer_Exception_TargetID_Wrong_Type, + new Object[] { targetID, IRCID.class.getName() })); if (connectWaiting) - throw new ContainerConnectException(Messages.IRCRootContainer_Connecting); + throw new ContainerConnectException( + Messages.IRCRootContainer_Connecting); - fireContainerEvent(new ContainerConnectingEvent(this.getID(), connectID, connectContext)); + fireContainerEvent(new ContainerConnectingEvent(this.getID(), + connectID, connectContext)); // Get password via callback in connectContext String pw = getPasswordFromConnectContext(connectContext); IRCID tID = (IRCID) connectID; @@ -93,9 +105,11 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer String name = null; boolean ssl = false; if (!ssl) { - connection = new IRCConnection(host, new int[] {port}, pass, nick, user, name); + connection = new IRCConnection(host, new int[] { port }, pass, + nick, user, name); } else { - connection = new SSLIRCConnection(host, new int[] {port}, pass, nick, user, name); + connection = new SSLIRCConnection(host, new int[] { port }, pass, + nick, user, name); } // connection setup connection.addIRCEventListener(getIRCEventListener()); @@ -115,14 +129,19 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer connectLock.wait(2000); } if (connectWaiting) - throw new TimeoutException(NLS.bind(Messages.IRCRootContainer_Connect_Timeout, tID.getName()), CONNECT_TIMEOUT); + throw new TimeoutException(NLS.bind( + Messages.IRCRootContainer_Connect_Timeout, tID + .getName()), CONNECT_TIMEOUT); if (connectException != null) throw connectException; this.targetID = tID; - fireContainerEvent(new ContainerConnectedEvent(getID(), this.targetID)); + fireContainerEvent(new ContainerConnectedEvent(getID(), + this.targetID)); } catch (Exception e) { this.targetID = null; - throw new ContainerConnectException(NLS.bind(Messages.IRCRootContainer_Exception_Connect_Failed, connectID.getName()), e); + throw new ContainerConnectException(NLS.bind( + Messages.IRCRootContainer_Exception_Connect_Failed, + connectID.getName()), e); } finally { connectWaiting = false; connectException = null; @@ -161,32 +180,38 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer synchronized (connectLock) { if (connectWaiting) { if (connectException == null) - connectException = new Exception(Messages.IRCRootContainer_Exception_Unexplained_Disconnect); + connectException = new Exception( + Messages.IRCRootContainer_Exception_Unexplained_Disconnect); connectWaiting = false; connectLock.notify(); } } if (targetID != null) { - showMessage(null, NLS.bind(Messages.IRCRootContainer_Disconnected, targetID.getName())); + showMessage(null, NLS.bind( + Messages.IRCRootContainer_Disconnected, targetID + .getName())); handleDisconnected(); } } public void onError(String arg0) { trace("handleOnError(" + arg0 + ")"); //$NON-NLS-1$ //$NON-NLS-2$ - showMessage(null, NLS.bind(Messages.IRCRootContainer_Error, arg0)); + showMessage(null, NLS.bind(Messages.IRCRootContainer_Error, + arg0)); handleErrorIfConnecting(arg0); } public void onError(int arg0, String arg1) { String msg = arg0 + "," + arg1; //$NON-NLS-1$ trace("handleOnError(" + msg + ")"); //$NON-NLS-1$ //$NON-NLS-2$ - showMessage(null, NLS.bind(Messages.IRCRootContainer_Error, msg)); + showMessage(null, NLS + .bind(Messages.IRCRootContainer_Error, msg)); handleErrorIfConnecting(arg0 + msg); } public void onInvite(String arg0, IRCUser arg1, String arg2) { - handleInvite(createIDFromString(arg0), createIDFromString(arg1.getNick())); + handleInvite(createIDFromString(arg0), createIDFromString(arg1 + .getNick())); } public void onJoin(String arg0, IRCUser arg1) { @@ -197,7 +222,8 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer } } - public void onKick(String channelName, IRCUser kicker, String kicked, String reason) { + public void onKick(String channelName, IRCUser kicker, + String kicked, String reason) { trace("handleOnKick(" + channelName + "," + kicker + "," //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + kicked + "," + reason + ")"); //$NON-NLS-1$ //$NON-NLS-2$ // retrieve the channel that this kick is happening at @@ -205,15 +231,24 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer if (channel != null) { // display a message to indicate that a user has been kicked // from the channel - showMessage(channelName, NLS.bind(Messages.IRCRootContainer_UserKicked, new Object[] {kicker.getNick(), kicked, channelName, reason})); + showMessage(channelName, NLS.bind( + Messages.IRCRootContainer_UserKicked, new Object[] { + kicker.getNick(), kicked, channelName, + reason })); // check if we are the ones that have been kicked if (kicked.equals(((IRCID) targetID).getUsername())) { // fire disconnection events for this channel container - channel.fireContainerEvent(new ContainerDisconnectingEvent(channel.getID(), channel.targetID)); - channel.firePresenceListeners(false, new String[] {kicked}); - channel.fireContainerEvent(new ContainerDisconnectedEvent(channel.getID(), channel.targetID)); + channel + .fireContainerEvent(new ContainerDisconnectingEvent( + channel.getID(), channel.targetID)); + channel.firePresenceListeners(false, + new String[] { kicked }); + channel + .fireContainerEvent(new ContainerDisconnectedEvent( + channel.getID(), channel.targetID)); } else { - channel.firePresenceListeners(false, new String[] {kicked}); + channel.firePresenceListeners(false, + new String[] { kicked }); } } } @@ -237,9 +272,11 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer public void onPart(String arg0, IRCUser arg1, String arg2) { trace("handleOnPart(" + arg0 + "," + arg1 + "," + arg2 + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - IRCChannelContainer channel = (IRCChannelContainer) channels.get(arg0); + IRCChannelContainer channel = (IRCChannelContainer) channels + .get(arg0); if (channel != null) { - channel.firePresenceListeners(false, new String[] {getIRCUserName(arg1)}); + channel.firePresenceListeners(false, + new String[] { getIRCUserName(arg1) }); } } @@ -255,7 +292,9 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer public void onPrivmsg(String arg0, IRCUser arg1, String arg2) { trace("handleOnPrivmsg(" + arg0 + "," + arg1 + "," + arg2 + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ if (arg2.equals("\01VERSION\01")) { //$NON-NLS-1$ - showMessage(null, NLS.bind(Messages.IRCRootContainer_CTCP_VERSION_Request, arg1.toString())); + showMessage(null, NLS.bind( + Messages.IRCRootContainer_CTCP_VERSION_Request, + arg1.toString())); } else { showMessage(arg0, arg1.toString(), arg2); } @@ -265,7 +304,8 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer public void onQuit(IRCUser arg0, String arg1) { trace("handleOnQuit(" + arg0 + "," + arg1 + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ for (Iterator i = channels.values().iterator(); i.hasNext();) { - IRCChannelContainer container = (IRCChannelContainer) i.next(); + IRCChannelContainer container = (IRCChannelContainer) i + .next(); container.handleUserQuit(getIRCUserName(arg0)); } } @@ -280,10 +320,13 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer handleSetSubject(arg0, arg1, arg2); } - public void unknown(String arg0, String arg1, String arg2, String arg3) { + public void unknown(String arg0, String arg1, String arg2, + String arg3) { trace("handleUnknown(" + arg0 + "," + arg1 + "," + arg2 + "," //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + arg3 + ")"); //$NON-NLS-1$ - showMessage(null, NLS.bind(Messages.IRCRootContainer_Unknown_Message, new Object[] {arg0, arg1, arg2, arg3})); + showMessage(null, NLS.bind( + Messages.IRCRootContainer_Unknown_Message, + new Object[] { arg0, arg1, arg2, arg3 })); } }; } @@ -323,13 +366,15 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer * @see org.eclipse.ecf.core.IContainer#getConnectNamespace() */ public Namespace getConnectNamespace() { - return IDFactory.getDefault().getNamespaceByName(IRCNamespace.IRC_SCHEME); + return IDFactory.getDefault().getNamespaceByName( + IRCNamespace.IRC_SCHEME); } public IChatRoomInfo getChatRoomInfo(final String roomName) { if (roomName == null) return new IChatRoomInfo() { - public IChatRoomContainer createChatRoomContainer() throws ContainerCreateException { + public IChatRoomContainer createChatRoomContainer() + throws ContainerCreateException { return IRCRootContainer.this; } @@ -374,13 +419,18 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer } }; return new IChatRoomInfo() { - public IChatRoomContainer createChatRoomContainer() throws ContainerCreateException { + public IChatRoomContainer createChatRoomContainer() + throws ContainerCreateException { try { - IRCChannelContainer newChannelContainer = new IRCChannelContainer(IRCRootContainer.this, IDFactory.getDefault().createGUID()); + IRCChannelContainer newChannelContainer = new IRCChannelContainer( + IRCRootContainer.this, IDFactory.getDefault() + .createGUID()); addChannel(roomName, newChannelContainer); return newChannelContainer; } catch (Exception e) { - throw new ContainerCreateException(Messages.IRCRootContainer_Exception_Create_ChatRoom, e); + throw new ContainerCreateException( + Messages.IRCRootContainer_Exception_Create_ChatRoom, + e); } } @@ -438,11 +488,13 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer return null; } - public void addChatRoomParticipantListener(IChatRoomParticipantListener participantListener) { + public void addChatRoomParticipantListener( + IChatRoomParticipantListener participantListener) { // for root container, no participant listening } - public void removeChatRoomParticipantListener(IChatRoomParticipantListener participantListener) { + public void removeChatRoomParticipantListener( + IChatRoomParticipantListener participantListener) { // for root container, no participant listening } @@ -452,13 +504,16 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer if (isCommand(message)) parseCommandAndSend(message, null, null); else - showErrorMessage(null, NLS.bind(Messages.IRCRootContainer_Command_Error, message, COMMAND_PREFIX)); + showErrorMessage(null, NLS.bind( + Messages.IRCRootContainer_Command_Error, message, + COMMAND_PREFIX)); } }; } /** - * Returns string from the buffer beginning up to nearest COMMAND_DELIM. Strips trailing COMMAND_DELIMs. + * Returns string from the buffer beginning up to nearest COMMAND_DELIM. + * Strips trailing COMMAND_DELIMs. * * @param buffer * @return String up to first COMMAND_DELIM occurrence in buffer. @@ -480,12 +535,14 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer token = buffer.substring(0, index); - /*if (token.length() == buffer.length()) { - //index = token.length() - 1; - } */ + /* + * if (token.length() == buffer.length()) { //index = token.length() - + * 1; } + */ // trim trailing command delims - while ((buffer.length() > index) && (buffer.indexOf(COMMAND_DELIM, index) == index)) { + while ((buffer.length() > index) + && (buffer.indexOf(COMMAND_DELIM, index) == index)) { index += COMMAND_DELIM.length(); } if (index > 0) { @@ -495,7 +552,8 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer return token; } - protected void parseCommandAndSend(String commandMessage, String channelName, String ircUser) { + protected void parseCommandAndSend(String commandMessage, + String channelName, String ircUser) { synchronized (this) { if (connection != null) { try { @@ -506,13 +564,19 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer commandMessage = commandMessage.substring(5); int index = commandMessage.indexOf(COMMAND_DELIM); if (index != -1) { - connection.doPrivmsg(commandMessage.substring(0, index), commandMessage.substring(index + 1)); + connection + .doPrivmsg(commandMessage.substring(0, + index), commandMessage + .substring(index + 1)); } } else if (lowerCase.startsWith("/privmsg ")) { //$NON-NLS-1$ commandMessage = commandMessage.substring(9); int index = commandMessage.indexOf(COMMAND_DELIM); if (index != -1) { - connection.doPrivmsg(commandMessage.substring(0, index), commandMessage.substring(index + 1)); + connection + .doPrivmsg(commandMessage.substring(0, + index), commandMessage + .substring(index + 1)); } } else if (lowerCase.startsWith("/op ")) { //$NON-NLS-1$ nextToken(command); // skip command @@ -583,7 +647,10 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer handleCommandMessage(tokens, channelName); } } catch (Exception e) { - showErrorMessage(channelName, NLS.bind(Messages.IRCRootContainer_Exception_Parse, new Object[] {e.getClass().getName(), e.getLocalizedMessage()})); + showErrorMessage(channelName, NLS.bind( + Messages.IRCRootContainer_Exception_Parse, + new Object[] { e.getClass().getName(), + e.getLocalizedMessage() })); traceStack(e, "PARSE ERROR: " + commandMessage); //$NON-NLS-1$ } } else { @@ -593,7 +660,8 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer } } - private synchronized void handleCommandMessage(String[] tokens, String channelName) { + private synchronized void handleCommandMessage(String[] tokens, + String channelName) { // Look at first one and switch String origCommand = tokens[0]; String command = origCommand; @@ -660,7 +728,9 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer connection.doInvite(args[0], args[1]); } } else { - String msg = NLS.bind(Messages.IRCRootContainer_Command_Unrecognized, origCommand); + String msg = NLS + .bind(Messages.IRCRootContainer_Command_Unrecognized, + origCommand); trace(msg + " in IRCContainer: " + getID()); //$NON-NLS-1$ showErrorMessage(channelName, msg); } @@ -669,7 +739,8 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer protected void handleInvite(ID channelID, ID fromID) { synchronized (invitationListeners) { for (int i = 0; i < invitationListeners.size(); i++) { - IChatRoomInvitationListener icril = (IChatRoomInvitationListener) invitationListeners.get(i); + IChatRoomInvitationListener icril = (IChatRoomInvitationListener) invitationListeners + .get(i); icril.handleInvitationReceived(channelID, fromID, null, null); } } @@ -687,9 +758,11 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer protected void showMessage(String channel, String msg) { IRCChannelContainer msgChannel = getChannel(channel); if (msgChannel != null) - msgChannel.fireChatRoomMessageEvent(createIDFromString(channel), msg); + msgChannel.fireChatRoomMessageEvent(createIDFromString(channel), + msg); else - fireChatRoomMessageEvent((channel == null) ? getSystemID() : createIDFromString(channel), msg); + fireChatRoomMessageEvent((channel == null) ? getSystemID() + : createIDFromString(channel), msg); } protected void showMessage(String channel, String user, String msg) { @@ -708,18 +781,23 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer void showErrorMessage(String channel, String msg) { IRCChannelContainer msgChannel = getChannel(channel); if (msgChannel != null) - msgChannel.fireChatRoomMessageEvent((username == null) ? getSystemID() : createIDFromString(username), msg); + msgChannel.fireChatRoomMessageEvent( + (username == null) ? getSystemID() + : createIDFromString(username), msg); else - fireChatRoomMessageEvent((username == null) ? getSystemID() : createIDFromString(username), msg); + fireChatRoomMessageEvent((username == null) ? getSystemID() + : createIDFromString(username), msg); } ID getSystemID() { if (targetID == null) return unknownID; try { - return IDFactory.getDefault().createStringID(((IRCID) targetID).getHost()); + return IDFactory.getDefault().createStringID( + ((IRCID) targetID).getHost()); } catch (IDCreateException e) { - Activator.log("ID creation exception in IRCContainer.getSystemID()", e); //$NON-NLS-1$ + Activator.log( + "ID creation exception in IRCContainer.getSystemID()", e); //$NON-NLS-1$ return unknownID; } } @@ -727,7 +805,8 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer protected void handle353Reply(String channel, String[] strings) { IRCChannelContainer container = getChannel(channel); if (container == null) { - showMessage(null, NLS.bind(Messages.IRCRootContainer_353_Error, channel)); + showMessage(null, NLS.bind(Messages.IRCRootContainer_353_Error, + channel)); } else container.firePresenceListeners(true, strings); } @@ -736,41 +815,46 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer public void handleReply(int code, String arg1, String arg2) { String[] users = parseUsers(arg1); switch (code) { - case 353 : - handle353Reply(users[2], parseUserNames(arg2)); - break; - case 311 : - showMessage(null, NLS.bind(Messages.IRCRootContainer_Whois, users[1])); - showMessage(null, trimUsername(users[2]) + "@" + users[3]); //$NON-NLS-1$ - break; - case 312 : - showMessage(null, NLS.bind(Messages.IRCRootContainer_Server, new Object[] {users[2], arg2})); - break; - case 317 : - showMessage(null, NLS.bind(Messages.IRCRootContainer_Idle, users[2])); - break; - case 318 : - showMessage(null, Messages.IRCRootContainer_Whois_End); - break; - case 319 : - showMessage(null, NLS.bind(Messages.IRCRootContainer_Channels, arg2)); - break; - case 320 : - break; - case 331 : - case 332 : - // Subject changes - String[] args = parseCommandTokens(arg1); - String channel = (args.length == 2) ? args[1] : ((args.length == 1) ? args[0] : null); - handleSetSubject(channel, null, arg2); - break; - default : - // first user always expected to be us - if (users.length < 2) - showMessage(null, arg2); - else { - showMessage(users[1], concat(users, 2, arg2)); - } + case 353: + handle353Reply(users[2], parseUserNames(arg2)); + break; + case 311: + showMessage(null, NLS.bind(Messages.IRCRootContainer_Whois, + users[1])); + showMessage(null, trimUsername(users[2]) + "@" + users[3]); //$NON-NLS-1$ + break; + case 312: + showMessage(null, NLS.bind(Messages.IRCRootContainer_Server, + new Object[] { users[2], arg2 })); + break; + case 317: + showMessage(null, NLS.bind(Messages.IRCRootContainer_Idle, + users[2])); + break; + case 318: + showMessage(null, Messages.IRCRootContainer_Whois_End); + break; + case 319: + showMessage(null, NLS.bind(Messages.IRCRootContainer_Channels, + arg2)); + break; + case 320: + break; + case 331: + case 332: + // Subject changes + String[] args = parseCommandTokens(arg1); + String channel = (args.length == 2) ? args[1] + : ((args.length == 1) ? args[0] : null); + handleSetSubject(channel, null, arg2); + break; + default: + // first user always expected to be us + if (users.length < 2) + showMessage(null, arg2); + else { + showMessage(users[1], concat(users, 2, arg2)); + } } } @@ -780,19 +864,24 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer } } - protected void handleSetSubject(String channelName, IRCUser user, String newSubject) { - IRCChannelContainer channel = (IRCChannelContainer) channels.get(channelName); + protected void handleSetSubject(String channelName, IRCUser user, + String newSubject) { + IRCChannelContainer channel = (IRCChannelContainer) channels + .get(channelName); if (channel == null) { showMessage(null, newSubject); fireSubjectListeners(null, newSubject); } else { String nickname = (user == null) ? null : user.getNick(); - ID fromID = (user == null) ? null : createIDFromString(getIRCUserName(user)); + ID fromID = (user == null) ? null + : createIDFromString(getIRCUserName(user)); // Put out message to channel if (nickname == null) showMessage(channelName, newSubject); else - showMessage(channelName, NLS.bind(Messages.IRCRootContainer_TopicChange, new Object[] {nickname, newSubject})); + showMessage(channelName, NLS.bind( + Messages.IRCRootContainer_TopicChange, new Object[] { + nickname, newSubject })); // Also notify subject listeners channel.fireSubjectListeners(fromID, newSubject); } @@ -814,7 +903,8 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer } } - protected void doSendChannelMessage(String channelName, String ircUser, String msg) { + protected void doSendChannelMessage(String channelName, String ircUser, + String msg) { if (connection != null) { // If it's a command, if (isCommand(msg)) { @@ -826,9 +916,11 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer } } - protected void doSendSubjectChangeMessage(String channelName, String topic) throws ECFException { + protected void doSendSubjectChangeMessage(String channelName, String topic) + throws ECFException { if (connection == null) - throw new ECFException(Messages.IRCRootContainer_Exception_Unexplained_Disconnect); + throw new ECFException( + Messages.IRCRootContainer_Exception_Unexplained_Disconnect); connection.doTopic(channelName, topic); } @@ -873,11 +965,14 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer /* * (non-Javadoc) * - * @see org.eclipse.ecf.presence.chatroom.IChatRoomManager#createChatRoom(java.lang.String, - * java.util.Map) + * @see + * org.eclipse.ecf.presence.chatroom.IChatRoomManager#createChatRoom(java + * .lang.String, java.util.Map) */ - public IChatRoomInfo createChatRoom(String roomname, Map properties) throws ChatRoomCreateException { - throw new ChatRoomCreateException(roomname, Messages.IRCRootContainer_Exception_Create_Not_Supported, null); + public IChatRoomInfo createChatRoom(String roomname, Map properties) + throws ChatRoomCreateException { + throw new ChatRoomCreateException(roomname, + Messages.IRCRootContainer_Exception_Create_Not_Supported, null); } protected IHistoryManager chatRoomHistoryManager = new IHistoryManager() { @@ -911,28 +1006,34 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer /* * (non-Javadoc) * - * @see org.eclipse.ecf.presence.chatroom.IChatRoomManager#getInvitationSender() + * @see + * org.eclipse.ecf.presence.chatroom.IChatRoomManager#getInvitationSender() */ public IChatRoomInvitationSender getInvitationSender() { return this; } - public void sendInvitation(ID room, ID targetUser, String subject, String body) throws ECFException { + public void sendInvitation(ID room, ID targetUser, String subject, + String body) throws ECFException { if (connection == null) - throw new ECFException(Messages.IRCRootContainer_EXCEPTION_CONNECTION_CANNOT_BE_NULL); + throw new ECFException( + Messages.IRCRootContainer_EXCEPTION_CONNECTION_CANNOT_BE_NULL); connection.doInvite(targetUser.getName(), room.getName()); } - public void sendChatMessage(ID toID, ID threadID, Type type, String subject, String body, Map properties) throws ECFException { + public void sendChatMessage(ID toID, ID threadID, Type type, + String subject, String body, Map properties) throws ECFException { sendChatMessage(toID, body); } public void sendChatMessage(ID toID, String body) throws ECFException { if (toID == null) { - throw new ECFException(Messages.IRCRootContainer_EXCEPTION_TARGETID_CANNOT_BE_NULL); + throw new ECFException( + Messages.IRCRootContainer_EXCEPTION_TARGETID_CANNOT_BE_NULL); } - // FIXME: temporary workaround to allow for the sending of messages to users that are operators + // FIXME: temporary workaround to allow for the sending of messages to + // users that are operators String name = toID.getName(); if (name.charAt(0) == '@') { name = name.substring(1); @@ -949,8 +1050,12 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer return new ID[0]; } - /* (non-Javadoc) - * @see org.eclipse.ecf.presence.chatroom.IChatRoomContainer#getChatRoomAdminSender() + /* + * (non-Javadoc) + * + * @see + * org.eclipse.ecf.presence.chatroom.IChatRoomContainer#getChatRoomAdminSender + * () */ public IChatRoomAdminSender getChatRoomAdminSender() { return null; |