Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2007-09-05 23:18:00 +0000
committerslewis2007-09-05 23:18:00 +0000
commite36eba6219db8705b4fa0a9b3aed26bde0e3daa1 (patch)
treea7307bdd537500940c43b1a4638c23521493f017 /providers/bundles/org.eclipse.ecf.provider.irc
parent7d965d115e1e9fa08777655b92c4f32a95c551e0 (diff)
downloadorg.eclipse.ecf-e36eba6219db8705b4fa0a9b3aed26bde0e3daa1.tar.gz
org.eclipse.ecf-e36eba6219db8705b4fa0a9b3aed26bde0e3daa1.tar.xz
org.eclipse.ecf-e36eba6219db8705b4fa0a9b3aed26bde0e3daa1.zip
Removed warning for unthrown exceptions. Corrected other warnings.
Diffstat (limited to 'providers/bundles/org.eclipse.ecf.provider.irc')
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.irc/.settings/org.eclipse.jdt.core.prefs4
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/Activator.java32
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/Messages.java10
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/container/IRCChannelContainer.java122
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/container/IRCRootContainer.java125
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/identity/IRCID.java43
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/identity/IRCNamespace.java41
-rw-r--r--providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/messages.properties5
8 files changed, 174 insertions, 208 deletions
diff --git a/providers/bundles/org.eclipse.ecf.provider.irc/.settings/org.eclipse.jdt.core.prefs b/providers/bundles/org.eclipse.ecf.provider.irc/.settings/org.eclipse.jdt.core.prefs
index 78523cd05..a2f9db0ae 100644
--- a/providers/bundles/org.eclipse.ecf.provider.irc/.settings/org.eclipse.jdt.core.prefs
+++ b/providers/bundles/org.eclipse.ecf.provider.irc/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Thu Aug 16 11:00:59 EDT 2007
+#Wed Sep 05 16:12:22 PDT 2007
eclipse.preferences.version=1
org.eclipse.jdt.core.builder.cleanOutputFolder=clean
org.eclipse.jdt.core.builder.duplicateResourceTask=warning
@@ -63,7 +63,7 @@ org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unsafeTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled
org.eclipse.jdt.core.compiler.problem.unusedImport=error
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
diff --git a/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/Activator.java b/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/Activator.java
index 12f3e492f..44a89650d 100644
--- a/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/Activator.java
+++ b/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/Activator.java
@@ -23,32 +23,28 @@ import org.osgi.util.tracker.ServiceTracker;
*/
public class Activator implements BundleActivator {
- public static final String NAMESPACE_IDENTIFIER = "ecfircid"; //$NON-NLS-1$
-
- public static final String PLUGIN_ID = "org.eclipse.ecf.provider.irc"; //$NON-NLS-1$
-
+ public static final String NAMESPACE_IDENTIFIER = "ecfircid"; //$NON-NLS-1$
+
+ public static final String PLUGIN_ID = "org.eclipse.ecf.provider.irc"; //$NON-NLS-1$
+
//The shared instance.
private static Activator plugin;
-
- private BundleContext context = null;
-
+
+ private BundleContext bundleContext = null;
+
private ServiceTracker logServiceTracker = null;
public static void log(String message) {
- getDefault().log(
- new Status(IStatus.OK, PLUGIN_ID, IStatus.OK, message, null));
+ getDefault().log(new Status(IStatus.OK, PLUGIN_ID, IStatus.OK, message, null));
}
public static void log(String message, Throwable e) {
- getDefault().log(
- new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK,
- "Caught exception", e)); //$NON-NLS-1$
+ getDefault().log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, "Caught exception", e)); //$NON-NLS-1$
}
protected LogService getLogService() {
if (logServiceTracker == null) {
- logServiceTracker = new ServiceTracker(this.context,
- LogService.class.getName(), null);
+ logServiceTracker = new ServiceTracker(this.bundleContext, LogService.class.getName(), null);
logServiceTracker.open();
}
return (LogService) logServiceTracker.getService();
@@ -57,12 +53,10 @@ public class Activator implements BundleActivator {
public void log(IStatus status) {
LogService logService = getLogService();
if (logService != null) {
- logService.log(LogHelper.getLogCode(status), LogHelper
- .getLogMessage(status), status.getException());
+ logService.log(LogHelper.getLogCode(status), LogHelper.getLogMessage(status), status.getException());
}
}
-
/**
* The constructor.
*/
@@ -74,7 +68,7 @@ public class Activator implements BundleActivator {
* This method is called upon plug-in activation
*/
public void start(BundleContext context) throws Exception {
- this.context = context;
+ this.bundleContext = context;
}
/**
@@ -85,7 +79,7 @@ public class Activator implements BundleActivator {
logServiceTracker.close();
logServiceTracker = null;
}
- this.context = null;
+ this.bundleContext = null;
plugin = null;
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/Messages.java b/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/Messages.java
index 53e5e4efa..4d3beeccd 100644
--- a/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/Messages.java
+++ b/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/Messages.java
@@ -16,6 +16,12 @@ public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.ecf.internal.provider.irc.messages"; //$NON-NLS-1$
+ public static String IRCNamespace_EXCEPTION_CREATE_CANNOT_CAST_TO_STRING;
+
+ public static String IRCNamespace_EXCEPTION_CREATING_URI;
+
+ public static String IRCNamespace_EXCEPTION_INVALID_PROTOCOL;
+
public static String IRCRootContainer_0;
public static String IRCRootContainer_Connect_Timeout;
@@ -24,6 +30,10 @@ public class Messages extends NLS {
public static String IRCRootContainer_Connecting_To;
+ public static String IRCRootContainer_EXCEPTION_CONNECTION_CANNOT_BE_NULL;
+
+ public static String IRCRootContainer_EXCEPTION_TARGETID_CANNOT_BE_NULL;
+
public static String IRCRootContainer_TopicChange;
public static String IRCRootContainer_UserKicked;
public static String IRCRootContainer_Disconnected;
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 6f34bbf66..3c2b59232 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
@@ -10,32 +10,17 @@
*****************************************************************************/
package org.eclipse.ecf.internal.provider.irc.container;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-
+import java.util.*;
import org.eclipse.ecf.core.ContainerConnectException;
-import org.eclipse.ecf.core.events.ContainerConnectedEvent;
-import org.eclipse.ecf.core.events.ContainerConnectingEvent;
-import org.eclipse.ecf.core.events.ContainerDisconnectedEvent;
-import org.eclipse.ecf.core.events.ContainerDisconnectingEvent;
-import org.eclipse.ecf.core.events.IContainerEvent;
-import org.eclipse.ecf.core.identity.ID;
-import org.eclipse.ecf.core.identity.IDFactory;
-import org.eclipse.ecf.core.identity.Namespace;
-import org.eclipse.ecf.core.identity.StringID;
+import org.eclipse.ecf.core.events.*;
+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.IChatRoomContainer;
-import org.eclipse.ecf.presence.chatroom.IChatRoomMessageSender;
-import org.eclipse.ecf.presence.chatroom.IChatRoomParticipantListener;
+import org.eclipse.ecf.presence.chatroom.*;
import org.eclipse.ecf.presence.im.IChatMessageSender;
import org.eclipse.osgi.util.NLS;
import org.schwering.irc.lib.IRCUser;
@@ -44,8 +29,7 @@ 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;
@@ -61,8 +45,7 @@ public class IRCChannelContainer extends IRCAbstractContainer implements
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);
}
};
@@ -76,30 +59,27 @@ public class IRCChannelContainer extends IRCAbstractContainer implements
*
* @see org.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) {
return new IPresence() {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = -7514227760059471898L;
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() {
@@ -111,8 +91,7 @@ public class IRCChannelContainer extends IRCAbstractContainer implements
}
public Type getType() {
- return (available ? IPresence.Type.AVAILABLE
- : IPresence.Type.UNAVAILABLE);
+ return (available ? IPresence.Type.AVAILABLE : IPresence.Type.UNAVAILABLE);
}
public Object getAdapter(Class adapter) {
@@ -129,15 +108,14 @@ public class IRCChannelContainer extends IRCAbstractContainer implements
if (containsChannelParticipant(participantID) == null) {
channelParticipants.add(participantID);
return true;
- } else
- return false;
+ }
+ return false;
}
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;
@@ -146,8 +124,7 @@ public class IRCChannelContainer extends IRCAbstractContainer implements
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;
@@ -161,10 +138,8 @@ public class IRCChannelContainer extends IRCAbstractContainer implements
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));
@@ -174,10 +149,8 @@ public class IRCChannelContainer extends IRCAbstractContainer implements
ID removeID = removeChannelParticipant(createIDFromString(users[j]));
if (removeID != null) {
// 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.handlePresenceUpdated(removeID, createPresence(false));
l.handleDeparted(new User(removeID));
@@ -217,7 +190,7 @@ public class IRCChannelContainer extends IRCAbstractContainer implements
}
}
} else
- firePresenceListeners(true, new String[] { getIRCUserName(user) });
+ firePresenceListeners(true, new String[] {getIRCUserName(user)});
}
protected void fireContainerEvent(IContainerEvent event) {
@@ -230,19 +203,15 @@ public class IRCChannelContainer extends IRCAbstractContainer implements
* @see org.eclipse.ecf.core.IContainer#connect(org.eclipse.ecf.core.identity.ID,
* org.eclipse.ecf.core.security.IConnectContext)
*/
- public void connect(ID targetID, IConnectContext connectContext)
- throws ContainerConnectException {
+ public void connect(ID connectID, IConnectContext connectContext) throws ContainerConnectException {
// Actually do join here
- if (targetID == null)
- throw new ContainerConnectException(
- Messages.IRCChannelContainer_Exception_TargetID_Null);
+ if (connectID == 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 = targetID.getName();
- fireContainerEvent(new ContainerConnectingEvent(this.getID(), targetID,
- connectContext));
+ String channelName = connectID.getName();
+ fireContainerEvent(new ContainerConnectingEvent(this.getID(), connectID, connectContext));
// Get password via callback in connectContext
String pw = getPasswordFromConnectContext(connectContext);
synchronized (connectLock) {
@@ -254,19 +223,11 @@ public class IRCChannelContainer extends IRCAbstractContainer implements
connectLock.wait(2000);
}
if (connectWaiting)
- throw new TimeoutException(
- CONNECT_TIMEOUT,
- NLS
- .bind(
- Messages.IRCChannelContainer_Exception_Connect_Timeout,
- targetID.getName()));
- this.targetID = targetID;
- fireContainerEvent(new ContainerConnectedEvent(this.getID(),
- this.targetID));
+ throw new TimeoutException(CONNECT_TIMEOUT, NLS.bind(Messages.IRCChannelContainer_Exception_Connect_Timeout, targetID.getName()));
+ this.targetID = connectID;
+ fireContainerEvent(new ContainerConnectedEvent(this.getID(), this.targetID));
} catch (Exception e) {
- throw new ContainerConnectException(NLS.bind(
- Messages.IRCChannelContainer_Exception_Connect_Failed,
- targetID.getName()), e);
+ throw new ContainerConnectException(NLS.bind(Messages.IRCChannelContainer_Exception_Connect_Failed, targetID.getName()), e);
} finally {
connectWaiting = false;
}
@@ -292,9 +253,8 @@ public class IRCChannelContainer extends IRCAbstractContainer implements
public Object getAdapter(Class serviceType) {
if (serviceType != null && serviceType.isInstance(this)) {
return this;
- } else {
- return null;
}
+ return null;
}
/*
@@ -303,22 +263,20 @@ public class IRCChannelContainer extends IRCAbstractContainer implements
* @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() {
return (channelOperator != null && isLocalUserChannelOperator(channelOperator));
}
- protected boolean isLocalUserChannelOperator(String channelOperator) {
- if (!isChannelOperator(channelOperator))
+ 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 (channelOperator.equals(localUserName))
+ if (chOperator.equals(localUserName))
return true;
return false;
}
@@ -327,16 +285,14 @@ public class IRCChannelContainer extends IRCAbstractContainer implements
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);
}
public void sendChatMessage(ID toID, String body) throws ECFException {
rootContainer.sendChatMessage(toID, body);
}
-
+
public IChatMessageSender getPrivateMessageSender() {
return this;
}
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 34562e74c..eaf51f3b4 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
@@ -52,9 +52,9 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer
private ArrayList invitationListeners;
- private Object connectLock = new Object();
- private boolean connectWaiting = false;
- private Exception connectException = null;
+ protected Object connectLock = new Object();
+ protected boolean connectWaiting = false;
+ protected Exception connectException = null;
public IRCRootContainer(ID localID) throws IDCreateException {
this.localID = localID;
@@ -69,20 +69,20 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer
* @see org.eclipse.ecf.core.IContainer#connect(org.eclipse.ecf.core.identity.ID,
* org.eclipse.ecf.core.security.IConnectContext)
*/
- public void connect(ID targetID, IConnectContext connectContext) throws ContainerConnectException {
+ public void connect(ID connectID, IConnectContext connectContext) throws ContainerConnectException {
if (connection != null)
throw new ContainerConnectException(Messages.IRCRootContainer_Exception_Already_Connected);
- if (targetID == null)
+ if (connectID == null)
throw new ContainerConnectException(Messages.IRCRootContainer_Exception_TargetID_Null);
- if (!(targetID instanceof IRCID))
+ if (!(connectID instanceof IRCID))
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);
- fireContainerEvent(new ContainerConnectingEvent(this.getID(), targetID, connectContext));
+ fireContainerEvent(new ContainerConnectingEvent(this.getID(), connectID, connectContext));
// Get password via callback in connectContext
String pw = getPasswordFromConnectContext(connectContext);
- IRCID tID = (IRCID) targetID;
+ IRCID tID = (IRCID) connectID;
String host = tID.getHost();
int port = tID.getPort();
String pass = pw;
@@ -312,9 +312,8 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer
public Object getAdapter(Class serviceType) {
if (serviceType != null && serviceType.isInstance(this)) {
return this;
- } else {
- return null;
}
+ return null;
}
/*
@@ -373,58 +372,57 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer
return null;
}
};
- else
- return new IChatRoomInfo() {
- public IChatRoomContainer createChatRoomContainer() throws ContainerCreateException {
- try {
- 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);
- }
+ return new IChatRoomInfo() {
+ public IChatRoomContainer createChatRoomContainer() throws ContainerCreateException {
+ try {
+ 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);
}
+ }
- public ID getConnectedID() {
- return IRCRootContainer.this.getConnectedID();
- }
+ public ID getConnectedID() {
+ return IRCRootContainer.this.getConnectedID();
+ }
- public String getDescription() {
- return ""; //$NON-NLS-1$
- }
+ public String getDescription() {
+ return ""; //$NON-NLS-1$
+ }
- public String getName() {
- return roomName;
- }
+ public String getName() {
+ return roomName;
+ }
- public int getParticipantsCount() {
- return 0;
- }
+ public int getParticipantsCount() {
+ return 0;
+ }
- public ID getRoomID() {
- return createIDFromString(roomName);
- }
+ public ID getRoomID() {
+ return createIDFromString(roomName);
+ }
- public String getSubject() {
- return ""; //$NON-NLS-1$
- }
+ public String getSubject() {
+ return ""; //$NON-NLS-1$
+ }
- public boolean isModerated() {
- return false;
- }
+ public boolean isModerated() {
+ return false;
+ }
- public boolean isPersistent() {
- return false;
- }
+ public boolean isPersistent() {
+ return false;
+ }
- public boolean requiresPassword() {
- return false;
- }
+ public boolean requiresPassword() {
+ return false;
+ }
- public Object getAdapter(Class adapter) {
- return null;
- }
- };
+ public Object getAdapter(Class adapter) {
+ return null;
+ }
+ };
}
public IChatRoomInfo[] getChatRoomInfos() {
@@ -444,6 +442,7 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer
}
public void removeChatRoomParticipantListener(IChatRoomParticipantListener participantListener) {
+ // for root container, no participant listening
}
public IChatRoomMessageSender getChatRoomMessageSender() {
@@ -666,7 +665,7 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer
}
}
- private void handleInvite(ID channelID, ID fromID) {
+ protected void handleInvite(ID channelID, ID fromID) {
synchronized (invitationListeners) {
for (int i = 0; i < invitationListeners.size(); i++) {
IChatRoomInvitationListener icril = (IChatRoomInvitationListener) invitationListeners.get(i);
@@ -684,7 +683,7 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer
return container;
}
- private void showMessage(String channel, String msg) {
+ protected void showMessage(String channel, String msg) {
IRCChannelContainer msgChannel = getChannel(channel);
if (msgChannel != null)
msgChannel.fireChatRoomMessageEvent(createIDFromString(channel), msg);
@@ -692,7 +691,7 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer
fireChatRoomMessageEvent((channel == null) ? getSystemID() : createIDFromString(channel), msg);
}
- private void showMessage(String channel, String user, String msg) {
+ protected void showMessage(String channel, String user, String msg) {
IRCChannelContainer msgChannel = getChannel(channel);
if (msgChannel != null) {
msgChannel.fireChatRoomMessageEvent(createIDFromString(user), msg);
@@ -705,7 +704,7 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer
}
}
- private void showErrorMessage(String channel, String msg) {
+ void showErrorMessage(String channel, String msg) {
IRCChannelContainer msgChannel = getChannel(channel);
if (msgChannel != null)
msgChannel.fireChatRoomMessageEvent((username == null) ? getSystemID() : createIDFromString(username), msg);
@@ -713,7 +712,7 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer
fireChatRoomMessageEvent((username == null) ? getSystemID() : createIDFromString(username), msg);
}
- private ID getSystemID() {
+ ID getSystemID() {
if (targetID == null)
return unknownID;
try {
@@ -842,8 +841,8 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer
if (connection == null) {
this.encoding = encoding;
return true;
- } else
- return false;
+ }
+ return false;
}
public void addInvitationListener(IChatRoomInvitationListener listener) {
@@ -912,11 +911,9 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer
}
public void sendInvitation(ID room, ID targetUser, String subject, String body) throws ECFException {
- if (connection == null) {
- throw new ECFException();
- } else {
- connection.doInvite(targetUser.getName(), room.getName());
- }
+ if (connection == 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 {
@@ -925,7 +922,7 @@ public class IRCRootContainer extends IRCAbstractContainer implements IContainer
public void sendChatMessage(ID toID, String body) throws ECFException {
if (toID == null) {
- throw new ECFException();
+ 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
diff --git a/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/identity/IRCID.java b/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/identity/IRCID.java
index 6deb7badd..808a3692a 100644
--- a/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/identity/IRCID.java
+++ b/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/identity/IRCID.java
@@ -11,7 +11,6 @@
package org.eclipse.ecf.internal.provider.irc.identity;
import java.net.URI;
-import java.net.URISyntaxException;
import org.eclipse.ecf.core.identity.BaseID;
import org.eclipse.ecf.core.identity.Namespace;
import org.eclipse.ecf.presence.im.IChatID;
@@ -19,19 +18,21 @@ import org.eclipse.ecf.presence.im.IChatID;
public class IRCID extends BaseID implements IChatID {
private static final long serialVersionUID = -6582811574473106742L;
public static final int DEFAULT_IRC_PORT = 6667;
-
+
URI uri;
-
+
protected IRCID(Namespace namespace, URI uri) {
super(namespace);
this.uri = uri;
}
+
/* (non-Javadoc)
* @see org.eclipse.ecf.core.identity.BaseID#namespaceCompareTo(org.eclipse.ecf.core.identity.BaseID)
*/
protected int namespaceCompareTo(BaseID o) {
- return getName().compareTo(o.getName());
+ return getName().compareTo(o.getName());
}
+
/* (non-Javadoc)
* @see org.eclipse.ecf.core.identity.BaseID#namespaceEquals(org.eclipse.ecf.core.identity.BaseID)
*/
@@ -42,59 +43,63 @@ public class IRCID extends BaseID implements IChatID {
IRCID other = (IRCID) o;
return uri.equals(other.uri);
}
+
/* (non-Javadoc)
* @see org.eclipse.ecf.core.identity.BaseID#namespaceGetName()
*/
protected String namespaceGetName() {
return uri.toString();
}
+
/* (non-Javadoc)
* @see org.eclipse.ecf.core.identity.BaseID#namespaceHashCode()
*/
protected int namespaceHashCode() {
return uri.hashCode();
}
- /* (non-Javadoc)
- * @see org.eclipse.ecf.core.identity.BaseID#namespaceToURI()
- */
- protected URI namespaceToURI() throws URISyntaxException {
- return uri;
- }
-
+
public String getUser() {
return uri.getUserInfo();
}
+
public String getHost() {
return uri.getHost();
}
-
+
public String getHostname() {
return getHost();
}
+
public int getPort() {
int p = uri.getPort();
- if (p == -1) return DEFAULT_IRC_PORT;
- else return p;
+ if (p == -1)
+ return DEFAULT_IRC_PORT;
+ return p;
}
+
public String getChannel() {
String frag = uri.getFragment();
- if (frag != null && !frag.equals("")) return "#"+frag; //$NON-NLS-1$ //$NON-NLS-2$
- else return null;
+ if (frag != null && !frag.equals(""))return "#" + frag; //$NON-NLS-1$ //$NON-NLS-2$
+ return null;
}
+
public String toString() {
StringBuffer sb = new StringBuffer("IRCID["); //$NON-NLS-1$
sb.append(uri.toString()).append(']');
return sb.toString();
}
+
public String getUsername() {
return getUser();
}
+
/* (non-Javadoc)
* @see org.eclipse.ecf.core.identity.BaseID#getAdapter(java.lang.Class)
*/
public Object getAdapter(Class clazz) {
- if (clazz.isInstance(this)) {
- return this;
- } else return super.getAdapter(clazz);
+ if (clazz.isInstance(this)) {
+ return this;
+ }
+ return super.getAdapter(clazz);
}
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/identity/IRCNamespace.java b/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/identity/IRCNamespace.java
index c1f0b11dc..222a84f9a 100644
--- a/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/identity/IRCNamespace.java
+++ b/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/identity/IRCNamespace.java
@@ -14,6 +14,8 @@ import java.net.URI;
import java.net.URISyntaxException;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.core.identity.IDCreateException;
+import org.eclipse.ecf.internal.provider.irc.Messages;
+import org.eclipse.osgi.util.NLS;
public class IRCNamespace extends org.eclipse.ecf.core.identity.Namespace {
@@ -22,7 +24,7 @@ public class IRCNamespace extends org.eclipse.ecf.core.identity.Namespace {
public static final String IRC_PROTOCOL = "irc"; //$NON-NLS-1$
private String getProtocolPrefix() {
- return getScheme()+"://";
+ return getScheme() + "://"; //$NON-NLS-1$
}
public ID createInstance(Object[] args) throws IDCreateException {
@@ -31,43 +33,40 @@ public class IRCNamespace extends org.eclipse.ecf.core.identity.Namespace {
try {
s = (String) args[0];
} catch (ClassCastException e) {
- throw new IDCreateException("Cannot cast argument " + args[0]
- + " to String");
+ throw new IDCreateException(NLS.bind(Messages.IRCNamespace_EXCEPTION_CREATE_CANNOT_CAST_TO_STRING, args[0]));
}
- if (!s.startsWith(getProtocolPrefix())) s = getProtocolPrefix()+s;
+ if (!s.startsWith(getProtocolPrefix()))
+ s = getProtocolPrefix() + s;
try {
newURI = createURI(s);
-// newURI = new URI(s);
} catch (URISyntaxException e) {
- throw new IDCreateException("Exception creating URI out of " + s);
+ throw new IDCreateException(NLS.bind(Messages.IRCNamespace_EXCEPTION_CREATING_URI, s));
}
String uriScheme = newURI.getScheme();
if (uriScheme == null || !uriScheme.equalsIgnoreCase(getScheme())) {
- throw new IDCreateException(newURI
- + " has invalid protocol. URI must have protocol "
- + IRC_PROTOCOL);
+ throw new IDCreateException(NLS.bind(Messages.IRCNamespace_EXCEPTION_INVALID_PROTOCOL, newURI, IRC_PROTOCOL));
}
return new IRCID(this, newURI);
}
- private URI createURI(String s) throws IDCreateException, URISyntaxException{
+ private URI createURI(String s) throws IDCreateException, URISyntaxException {
URI ret = null;
- String uname = s.substring(getProtocolPrefix().length(),s.indexOf("@"));
- int hostend = s.lastIndexOf("/");
- int hoststart = s.indexOf("@");
- if(hoststart > hostend || hostend == -1){
+ String uname = s.substring(getProtocolPrefix().length(), s.indexOf("@")); //$NON-NLS-1$
+ int hostend = s.lastIndexOf("/"); //$NON-NLS-1$
+ int hoststart = s.indexOf("@"); //$NON-NLS-1$
+ if (hoststart > hostend || hostend == -1) {
hostend = s.length();
}
- String host = s.substring(hoststart+1,hostend);
+ String host = s.substring(hoststart + 1, hostend);
int port = -1;
- int portidx = host.indexOf(":");
- if(portidx >= 0){
- port = Integer.parseInt(host.substring(portidx+1,host.length()));
- host = host.substring(0,portidx);
+ int portidx = host.indexOf(":"); //$NON-NLS-1$
+ if (portidx >= 0) {
+ port = Integer.parseInt(host.substring(portidx + 1, host.length()));
+ host = host.substring(0, portidx);
}
String path = s.substring(hostend, s.length());
- ret = new URI(getScheme(),uname,host,port,path,null,null);
+ ret = new URI(getScheme(), uname, host, port, path, null, null);
return ret;
}
@@ -82,6 +81,6 @@ public class IRCNamespace extends org.eclipse.ecf.core.identity.Namespace {
* @see org.eclipse.ecf.core.identity.Namespace#getSupportedParameterTypesForCreateInstance()
*/
public Class[][] getSupportedParameterTypes() {
- return new Class[][] { { String.class } };
+ return new Class[][] {{String.class}};
}
}
diff --git a/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/messages.properties b/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/messages.properties
index 3b39aa9f0..d879c6aa4 100644
--- a/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/messages.properties
+++ b/providers/bundles/org.eclipse.ecf.provider.irc/src/org/eclipse/ecf/internal/provider/irc/messages.properties
@@ -35,6 +35,8 @@ IRCRootContainer_Exception_TargetID_Null = targetID cannot be null
IRCRootContainer_Exception_TargetID_Wrong_Type = targetID {0} not instance of {1}
IRCRootContainer_Exception_Connect_Failed = Connect failed to {0}
IRCRootContainer_Exception_Unexplained_Disconnect = Unexplained disconnection
+IRCRootContainer_EXCEPTION_CONNECTION_CANNOT_BE_NULL=connection cannot be null
+IRCRootContainer_EXCEPTION_TARGETID_CANNOT_BE_NULL=targetID cannot be null
IRCRootContainer_Exception_Create_ChatRoom = Exception creating IRCChannelContainer
IRCRootContainer_Exception_Parse = EXCEPTION PARSING: {0}. Message: {1}
IRCRootContainer_Connect_Timeout=Timeout connecting to {0}
@@ -43,7 +45,10 @@ IRCRootContainer_Exception_Create_Not_Supported = Creation not supported
IRCRootContainer_CTCP_VERSION_Request = Received a CTCP VERSION from {0}
IRCChannelContainer_Exception_Connecting = Connecting
+IRCNamespace_EXCEPTION_INVALID_PROTOCOL={0} has invalid protocol. URI must have protocol {1}
IRCChannelContainer_Exception_TargetID_Null = targetID cannot be null
IRCChannelContainer_Exception_Connect_Failed = Connect failed to {0}
IRCChannelContainer_Exception_Connect_Timeout = Timeout connecting to {0}
IRCContainerInstantiator_Exception_CreateID_Failed = Exception creating ID
+IRCNamespace_EXCEPTION_CREATE_CANNOT_CAST_TO_STRING=Cannot cast argument {0} to String.
+IRCNamespace_EXCEPTION_CREATING_URI=Exception creating URI out of {0}.

Back to the top